Set up new signals in EventBus; preparing to restructure game start

code.
This commit is contained in:
Henry 2025-12-20 09:15:59 +00:00
parent 7ef6076eda
commit dec3cbe595
9 changed files with 34 additions and 14 deletions

10
main.gd
View file

@ -1,7 +1,6 @@
extends Node2D
var enemy = preload("res://enemy.tscn")
var score = 0
var playing = false
var enemy_count: int = 0
@ -28,9 +27,9 @@ func spawn_enemies():
func _on_enemy_died(value: int):
score += value
Global.score += value
enemy_count -= 1
$CanvasLayer/UI.update_score(score)
$CanvasLayer/UI.update_score(Global.score)
print_debug(enemy_count)
if enemy_count == 0:
print("All enemies defeated!")
@ -45,8 +44,9 @@ func _on_player_died():
start_button.show()
func new_game():
score = 0
$CanvasLayer/UI.update_score(score)
Global.score = 0
EventBus.initialize_shieldbar.emit()
$CanvasLayer/UI.update_score(Global.score)
$Player.start()
spawn_enemies()
playing = true