DuckRun/code/main.gd
2024-10-22 19:52:35 +02:00

34 lines
1,002 B
GDScript

extends Node
func _ready() -> void:
$Fade/FadeAnimation.play_backwards("fade")
$Screen/Background/Floor/EasterEggFixCollision.disabled = false
$Gui/HiscoreContainer.show()
%ScoreContainer.hide()
func start_game():
$Screen/Background/Floor/EasterEggFixCollision.disabled = true
$Screen/HindernissSpawner.del_all()
$Gui/EastereggSpawner.del_all()
$Screen/SpawnTimer.start()
$Screen/LevelUpTimer.start()
$Screen/Duck.start()
$Gui/HiscoreContainer.hide()
%ScoreContainer.show()
$"/root/Global".gamerunning = true
$"/root/Global".start.emit()
$"/root/Global".score = 0
$"/root/Global".speed = 100
print("game started")
func _on_level_up_timer_timeout() -> void:
if $"/root/Global".speed < $"/root/Global".maxspeed:
$"/root/Global".speed += 10
$"/root/Global".levelup.emit()
func _score() -> void:
if not $"/root/Global".gamerunning:
%ScoreContainer/score.text = ""
elif $Screen/Duck.alive:
$"/root/Global".score += 10
%ScoreContainer/score.text = str($"/root/Global".score)