Added shoot-to-start game code, re-ordered starting sequence using
"playing" variable.
This commit is contained in:
parent
099440d27f
commit
ec7a84c252
4 changed files with 33 additions and 11 deletions
14
main.gd
14
main.gd
|
|
@ -12,6 +12,8 @@ func _ready():
|
|||
start_button.show()
|
||||
EventBus.player_died.connect(_on_player_died)
|
||||
EventBus.enemy_died.connect(_on_enemy_died)
|
||||
|
||||
|
||||
# spawn_enemies()
|
||||
|
||||
func spawn_enemies():
|
||||
|
|
@ -36,21 +38,28 @@ func _on_enemy_died(value: int):
|
|||
win_game()
|
||||
|
||||
func _on_player_died():
|
||||
playing = false
|
||||
get_tree().call_group("enemies", "queue_free")
|
||||
game_over.show()
|
||||
await get_tree().create_timer(2).timeout
|
||||
game_over.hide()
|
||||
start_button.show()
|
||||
playing = false
|
||||
|
||||
func new_game():
|
||||
Global.score = 0
|
||||
EventBus.initialize_shieldbar.emit()
|
||||
# EventBus.initialize_shieldbar.emit()
|
||||
$Player.start()
|
||||
$CanvasLayer/UI.update_score(Global.score)
|
||||
spawn_enemies()
|
||||
playing = true
|
||||
|
||||
|
||||
func _input(EventInput):
|
||||
if EventInput.is_action_pressed("shoot") and playing == false:
|
||||
print("Input detected!")
|
||||
start_button.hide()
|
||||
new_game()
|
||||
|
||||
func _on_start_pressed():
|
||||
start_button.hide()
|
||||
new_game()
|
||||
|
|
@ -58,6 +67,7 @@ func _on_start_pressed():
|
|||
func win_game():
|
||||
playing = false
|
||||
game_over.show()
|
||||
$Player._on_game_over()
|
||||
await get_tree().create_timer(2).timeout
|
||||
game_over.hide()
|
||||
start_button.show()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue