DuckRun/code/main.gd

47 lines
1.5 KiB
GDScript3
Raw Normal View History

2024-10-01 15:56:30 +02:00
extends Node
var biom_n = preload("res://assets/Ground/normal.png")
var biom_n_w = preload("res://assets/Ground/normal_wueste.png")
var biom_w = preload("res://assets/Ground/wueste.png")
2024-10-01 15:56:30 +02:00
func _ready() -> void:
$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/SpawnTimer.start()
$Screen/LevelUpTimer.start()
$Screen/Duck.start()
$Screen/HindernissSpawner.del_all()
$Screen/EastereggSpawner.del_all()
$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
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)
2024-10-01 15:56:30 +02:00
func _process(delta):
var background_size_x = $Screen/Background/Sprite.texture.get_size().x
var bla = (background_size_x) + $Screen/Background/Sprite.position.x
2024-10-01 15:56:30 +02:00
if $"/root/Global".gamerunning:
$Screen/Background/Sprite.position.x -= $"/root/Global".speed*delta
if bla <= 0:
#$Screen/Background/Sprite.texture =biom_n_w
$Screen/Background/Sprite.position.x = 0
2024-10-01 15:56:30 +02:00