sagar007 commited on
Commit
dacd0b6
·
verified ·
1 Parent(s): d57d3ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -26
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import gradio as gr
2
- import os
3
 
4
- # HTML content for the game
5
  html_content = """
6
  <!DOCTYPE html>
7
  <html>
@@ -408,30 +407,26 @@ html_content = """
408
  </html>
409
  """
410
 
411
- # Function to create an HTML file
412
- def create_html_file():
413
- # Make sure the app directory exists
414
- os.makedirs("app", exist_ok=True)
 
 
 
415
 
416
- # Write the HTML content to a file
417
- with open("app/index.html", "w") as f:
418
- f.write(html_content)
419
 
420
- return "app/index.html"
421
-
422
- # Gradio interface
423
- def create_interface():
424
- html_path = create_html_file()
425
 
426
- # Create a Gradio interface with HTML
427
- demo = gr.Interface(
428
- fn=lambda: None, # No-op function as we're just displaying static HTML
429
- inputs=None,
430
- outputs=gr.HTML(value=open(html_path, "r").read(), elem_id="bird-game"),
431
- title="Bird Shooter Game",
432
- description="Click on the birds to shoot them and earn points!",
433
- css="""
434
- .gradio-container {
435
- max-width: 850px !important;
436
- }
437
- #
 
1
  import gradio as gr
 
2
 
3
+ # The HTML content of the bird shooter game
4
  html_content = """
5
  <!DOCTYPE html>
6
  <html>
 
407
  </html>
408
  """
409
 
410
+ def create_game():
411
+ return gr.HTML(html_content, height=650)
412
+
413
+ # Create Gradio interface
414
+ with gr.Blocks(title="Bird Shooter Game") as demo:
415
+ gr.Markdown("# 🎮 Bird Shooter Game")
416
+ gr.Markdown("Click on the birds to shoot them and score points!")
417
 
418
+ game_interface = create_game()
 
 
419
 
420
+ gr.Markdown("""
421
+ ## How to Play
422
+ - Click on birds to shoot them
423
+ - Each hit earns you 10 points
424
+ - Try to get the highest score possible!
425
 
426
+ ## About
427
+ This is a simple bird shooter game created with SVG and JavaScript, embedded in a Gradio app for Hugging Face Spaces.
428
+ """)
429
+
430
+ # Launch the app
431
+ if __name__ == "__main__":
432
+ demo.launch()