Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import random
|
3 |
+
from game_dev_snippet import run_game
|
4 |
+
from mad_lib_generator import generate_mad_lib
|
5 |
+
|
6 |
+
st.set_page_config(layout="wide")
|
7 |
+
|
8 |
+
st.title("Game Development and Creative Writing Showcase")
|
9 |
+
|
10 |
+
col1, col2 = st.columns(2)
|
11 |
+
|
12 |
+
with col1:
|
13 |
+
st.header("Game Development")
|
14 |
+
st.code(run_game.__code__.co_code, language="python")
|
15 |
+
if st.button("Run Game"):
|
16 |
+
st.write("Game running in a separate window...")
|
17 |
+
run_game()
|
18 |
+
|
19 |
+
with col2:
|
20 |
+
st.header("Mad Lib Generator")
|
21 |
+
if st.button("Generate Mad Lib"):
|
22 |
+
st.write(generate_mad_lib())
|
23 |
+
|
24 |
+
st.header("D&D SVG Sprite Animation")
|
25 |
+
st.components.v1.html("""
|
26 |
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200" width="400" height="400">
|
27 |
+
<style>
|
28 |
+
@keyframes move {
|
29 |
+
0% { transform: translateX(0); }
|
30 |
+
50% { transform: translateX(100px); }
|
31 |
+
100% { transform: translateX(0); }
|
32 |
+
}
|
33 |
+
.sprite { animation: move 4s infinite; }
|
34 |
+
</style>
|
35 |
+
|
36 |
+
<g class="sprite">
|
37 |
+
<!-- Wizard sprite -->
|
38 |
+
<path d="M50,150 L70,100 L90,150 Z" fill="#4a0e4e" />
|
39 |
+
<circle cx="80" cy="90" r="20" fill="#c8a2c8" />
|
40 |
+
<path d="M70,90 Q80,70 90,90" stroke="#4a0e4e" stroke-width="2" fill="none" />
|
41 |
+
</g>
|
42 |
+
|
43 |
+
<!-- Background elements -->
|
44 |
+
<rect x="0" y="150" width="200" height="50" fill="#3a7d44" />
|
45 |
+
<circle cx="30" cy="30" r="15" fill="#f9d71c" />
|
46 |
+
</svg>
|
47 |
+
""", height=400)
|
48 |
+
|
49 |
+
st.header("Three.js 3D App")
|
50 |
+
st.components.v1.html("""
|
51 |
+
<!DOCTYPE html>
|
52 |
+
<html>
|
53 |
+
<head>
|
54 |
+
<meta charset="utf-8">
|
55 |
+
<title>Three.js Cube</title>
|
56 |
+
<style>
|
57 |
+
body { margin: 0; }
|
58 |
+
canvas { display: block; }
|
59 |
+
</style>
|
60 |
+
</head>
|
61 |
+
<body>
|
62 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
|
63 |
+
<script>
|
64 |
+
const scene = new THREE.Scene();
|
65 |
+
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
|
66 |
+
const renderer = new THREE.WebGLRenderer();
|
67 |
+
renderer.setSize(400, 300);
|
68 |
+
document.body.appendChild(renderer.domElement);
|
69 |
+
|
70 |
+
const geometry = new THREE.BoxGeometry();
|
71 |
+
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
|
72 |
+
const cube = new THREE.Mesh(geometry, material);
|
73 |
+
scene.add(cube);
|
74 |
+
|
75 |
+
camera.position.z = 5;
|
76 |
+
|
77 |
+
function animate() {
|
78 |
+
requestAnimationFrame(animate);
|
79 |
+
cube.rotation.x += 0.01;
|
80 |
+
cube.rotation.y += 0.01;
|
81 |
+
renderer.render(scene, camera);
|
82 |
+
}
|
83 |
+
animate();
|
84 |
+
</script>
|
85 |
+
</body>
|
86 |
+
</html>
|
87 |
+
""", height=300)
|
88 |
+
|
89 |
+
if __name__ == "__main__":
|
90 |
+
st.sidebar.title("Navigation")
|
91 |
+
st.sidebar.info("Use the buttons and sections above to interact with different components of the app.")
|