Spaces:
Sleeping
Sleeping
Commit
·
d0f1837
1
Parent(s):
b8a1a18
change
Browse files
app.py
CHANGED
@@ -10,8 +10,8 @@ def update_game(command, height, gap_position, bird_position, score, game_over):
|
|
10 |
GAME_HEIGHT = 5
|
11 |
GAP_SIZE = 2
|
12 |
|
13 |
-
if game_over:
|
14 |
-
return
|
15 |
|
16 |
# Move bird based on command
|
17 |
bird_position += 1 if command.lower() != "flap" else -1
|
@@ -52,7 +52,7 @@ def get_game_state(height, gap_position, bird_position, score):
|
|
52 |
iface = gr.Interface(
|
53 |
fn=update_game,
|
54 |
inputs=[
|
55 |
-
gr.
|
56 |
gr.State(),
|
57 |
gr.State(),
|
58 |
gr.State(),
|
@@ -68,10 +68,8 @@ iface = gr.Interface(
|
|
68 |
gr.State()
|
69 |
],
|
70 |
title="Simple Text-based Flappy Bird Game",
|
71 |
-
description="
|
72 |
)
|
73 |
|
74 |
-
iface.add_component(gr.Button("Start").click(flappy_bird, [], ["game_state", "height", "gap_position", "bird_position", "score", "game_over"]), "above")
|
75 |
-
|
76 |
if __name__ == "__main__":
|
77 |
iface.launch()
|
|
|
10 |
GAME_HEIGHT = 5
|
11 |
GAP_SIZE = 2
|
12 |
|
13 |
+
if game_over or command == "start":
|
14 |
+
return get_game_state(2, 2, 0, 0), 0, 2, 2, 0, False
|
15 |
|
16 |
# Move bird based on command
|
17 |
bird_position += 1 if command.lower() != "flap" else -1
|
|
|
52 |
iface = gr.Interface(
|
53 |
fn=update_game,
|
54 |
inputs=[
|
55 |
+
gr.Dropdown(choices=["flap", "start"], label="Control"),
|
56 |
gr.State(),
|
57 |
gr.State(),
|
58 |
gr.State(),
|
|
|
68 |
gr.State()
|
69 |
],
|
70 |
title="Simple Text-based Flappy Bird Game",
|
71 |
+
description="Use the dropdown to 'Start' the game or 'Flap' to move the bird up. Avoid the pipes!"
|
72 |
)
|
73 |
|
|
|
|
|
74 |
if __name__ == "__main__":
|
75 |
iface.launch()
|