dinosaur game in google chrome
To upload files, please first save the app
import streamlit as st
import numpy as np
st.title("Dinosaur Game")
st.write("Press the space bar to start the game")
# Game state
if "score" not in st.session_state:
st.session_state.score = 0
st.session_state.game_running = False
# Start or reset game
if st.button("Start Game"):
st.session_state.score = 0
st.session_state.game_running = True
# Game loop (simple simulation)
if st.session_state.game_running:
game_over = False
while not game_over:
st.session_state.score += np.random.randint(1, 6) # Random score increment
st.write(f"Score: {st.session_state.score}")
if st.button("Jump"):
st.write("Jumping!")
st.write("You avoided a cactus!")
if st.button("Game Over"):
game_over = True
st.session_state.game_running = False
st.write("Game Over! Final Score: ", st.session_state.score)
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?