Commented main game's functionality to better track what's happening.

This commit is contained in:
Henry 2025-12-24 13:29:59 +00:00
parent aa7cdc90d6
commit be3919acd7
2 changed files with 29 additions and 15 deletions

26
main.gd
View file

@ -17,7 +17,7 @@ func _ready():
func spawn_enemies():
get_tree().call_group("enemies", "queue_free")
for x in range(9):
for y in range(3):
var e = enemy.instantiate()
@ -25,7 +25,7 @@ func spawn_enemies():
add_child(e)
e.start(pos)
enemy_count = get_tree().get_nodes_in_group("enemies").size()
print(enemy_count)
print("Remaining enemies: ", enemy_count)
func _on_enemy_died(value: int):
@ -41,6 +41,7 @@ func _on_player_died():
# get_tree().call_group("enemies", "queue_free")
EventBus.enemy_win.emit()
# $Player.set_process(false)
# get_tree().call_group("enemies", "set_process", false)
instance.queue_free()
game_over.show()
await get_tree().create_timer(2).timeout
@ -49,23 +50,32 @@ func _on_player_died():
playing = false
func new_game():
# Ensure enemies are cleared.
enemy_count = 0
get_tree().call_group("enemies", "queue_free")
get_tree().call_group("enemy_bullets", "queue_free")
# get_node("player").start()
print("Number of enemies at new_game: ",enemy_count)
# Reset score.
Global.score = 0
$CanvasLayer/UI.update_score(Global.score)
EventBus.initialize_shieldbar.emit()
# instantiate the Player
instance = player.instantiate()
add_child(instance)
$Player.shader_active = false
$Player.start()
$CanvasLayer/UI.update_score(Global.score)
# Tell the shield to recharge.
EventBus.initialize_shieldbar.emit()
# Tell the enemies to spawn!
spawn_enemies()
# Tell the game we're playing.
playing = true
print("New game started!")
func _input(EventInput):
if EventInput.is_action_pressed("shoot") and playing == false:
print("Input detected!")
@ -79,7 +89,7 @@ func _on_start_pressed():
func win_game():
playing = false
game_over.show()
$Player._on_game_over()
$Player._on_player_victory()
await get_tree().create_timer(2).timeout
game_over.hide()
start_button.show()