DuckRun/code/main.gd

36 lines
1 KiB
GDScript3
Raw Permalink Normal View History

2024-10-01 15:56:30 +02:00
extends Node
func _ready() -> void:
$Fade/Animation.play_backwards("fade")
2024-10-01 15:56:30 +02:00
$Screen/Background/Floor/EasterEggFixCollision.disabled = false
$Gui/HiscoreContainer.show()
%ScoreContainer.hide()
2024-10-01 15:56:30 +02:00
func start_game():
$Screen/Background/Floor/EasterEggFixCollision.disabled = true
$Screen/HurdleSpawner.del_all()
$Gui/EastereggSpawner.del_all()
2024-10-01 15:56:30 +02:00
$Screen/SpawnTimer.start()
$Screen/CoinSpawnTimer.start()
2024-10-01 15:56:30 +02:00
$Screen/LevelUpTimer.start()
$Screen/Duck.start()
$Gui/HiscoreContainer.hide()
%ScoreContainer.show()
2024-10-01 15:56:30 +02:00
$"/root/Global".gamerunning = true
$"/root/Global".start.emit()
$"/root/Global".score = 0
$"/root/Global".speed = 100
2024-10-22 19:52:35 +02:00
print("game started")
2024-10-01 15:56:30 +02:00
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 = ""
2024-10-01 15:56:30 +02:00
elif $Screen/Duck.alive:
$"/root/Global".score += 10
%ScoreContainer/score.text = str($"/root/Global".score)