38 lines
1 KiB
GDScript3
38 lines
1 KiB
GDScript3
|
extends Node
|
||
|
|
||
|
func _ready() -> void:
|
||
|
$Screen/Background/Floor/EasterEggFixCollision.disabled = false
|
||
|
|
||
|
func start_game():
|
||
|
$Screen/Background/Floor/EasterEggFixCollision.disabled = true
|
||
|
$Screen/SpawnTimer.start()
|
||
|
$Screen/LevelUpTimer.start()
|
||
|
$Screen/Duck.start()
|
||
|
$Screen/HindernissSpawner.del_all()
|
||
|
$Screen/EastereggSpawner.del_all()
|
||
|
$"/root/Global".gamerunning = true
|
||
|
$"/root/Global".start.emit()
|
||
|
$"/root/Global".score = 0
|
||
|
$"/root/Global".speed = 100
|
||
|
|
||
|
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:
|
||
|
$Gui/Score.text = ""
|
||
|
elif $Screen/Duck.alive:
|
||
|
$"/root/Global".score += 10
|
||
|
$Gui/Score.text = "Score: "+str($"/root/Global".score)
|
||
|
|
||
|
|
||
|
|
||
|
func _process(delta):
|
||
|
if $"/root/Global".gamerunning:
|
||
|
$Screen/Background/Sprites.position.x -= $"/root/Global".speed*delta
|
||
|
if $Screen/Background/Sprites.position.x <= -200:
|
||
|
$Screen/Background/Sprites.position.x = 0
|
||
|
|