import streamlit as st import streamlit.components.v1 as components st.set_page_config(page_title="Galaxian Snake 3D", layout="wide") st.title("Galaxian Snake 3D") st.write("Navigate a 3D city as a snake, eating food and avoiding obstacles!") # Sliders for container size with initial 3:4 aspect ratio max_width = min(1200, st.session_state.get('window_width', 1200)) max_height = min(1600, st.session_state.get('window_height', 1600)) col1, col2 = st.columns(2) with col1: container_width = st.slider("Container Width (px)", 300, max_width, 768, step=50) with col2: container_height = st.slider("Container Height (px)", 400, max_height, 1024, step=50) # Player name input player_name = st.sidebar.text_input("Enter 3-letter name (e.g., ABC):", max_chars=3, value="XYZ").upper() if len(player_name) != 3 or not player_name.isalpha(): st.warning("Please enter a valid 3-letter name using A-Z.") player_name = "XYZ" html_code = f""" Galaxian Snake 3D

Galaxian Snake 3D

Score: 0
Time: 0
Length: 3
Lives: 3

Controls: W/A/S/D or Arrow Keys to move, R to reset

Eat yellow cubes to grow and score points!

""" # Render the HTML component with dynamic size components.html(html_code, width=container_width, height=container_height) st.sidebar.title("Galaxian Snake 3D") st.sidebar.write(""" ## How to Play Navigate a snake through a 3D city, eating food and avoiding obstacles. ### Controls: - **W/A/S/D or Arrow Keys**: Move snake - **R**: Reset after game over - **Sliders**: Adjust play area size ### Features: - 3:4 initial play area (768x1024) - Dynamic leaderboard in-game - City with buildings and roads - Quine agents (cyan spheres) orbit creatures - Scoring: 2 pts for doubling length, +2 pts/sec, +4 pts/sec after 10 units, 10 pt bonus at 10+ - 5-minute game duration """)