import gradio as gr
import tempfile
import os
# Create a temporary HTML file with the game
def create_game_html():
html_content = """
Bird Shooter Game
Score: 0
GAME OVER
"""
# Create a temporary file to serve the HTML
temp_dir = tempfile.mkdtemp()
html_path = os.path.join(temp_dir, "game.html")
with open(html_path, "w") as f:
f.write(html_content)
# Return the path to be used in the iframe
return html_path
def create_game():
html_path = create_game_html()
iframe_html = f''
return gr.HTML(iframe_html)
# Create Gradio interface
with gr.Blocks(title="Bird Shooter Game") as demo:
gr.Markdown("# 🎮 Bird Shooter Game")
gr.Markdown("Click on the birds to shoot them and score points!")
game_interface = create_game()
gr.Markdown("""
## How to Play
- Click on birds to shoot them
- Each hit earns you 10 points
- Try to get the highest score possible!
## About
This is a simple bird shooter game created with SVG and JavaScript, embedded in a Gradio app for Hugging Face Spaces.
""")
# Launch the app
if __name__ == "__main__":
demo.launch()