DuckRun/scenes/Duck/Duck.gd
megamichi 4676b83b61 - Musik Hinzugefügt
- Settings für Musik
- Angefangen mit Wüstenbiom
- Wolken Texture fix
2024-10-08 20:53:45 +02:00

55 lines
1.2 KiB
GDScript

extends CharacterBody2D
const JUMP_VELOCITY = -230.0
signal gameover
@onready var alive = true
var state = "main-menu"
func die():
print("die")
gameover.emit()
alive = false
func start():
global_position = Vector2(21,91)
alive = true
func _physics_process(delta: float) -> void:
if not is_on_floor():
velocity += get_gravity() * delta
if Input.is_action_pressed("jump") and is_on_floor() and alive and $"/root/Global".gamerunning:
velocity.y = JUMP_VELOCITY
move_and_slide()
func _process(_delta: float) -> void:
if position.x < -20:
if alive:
die()
if $"/root/Global".gamerunning:
state = "game"
if state == "main-menu" :
$AnimationPlayer.play("idle")
elif state == "game":
if not is_on_floor():
$AnimationPlayer.play("fly")
elif not alive:
$AnimationPlayer.play("die")
else:
$AnimationPlayer.play("walk")
func _collide_with_hindernis(_body: Node2D) -> void:
if alive:
die()
func _color_slider_changed(value) -> void:
$EnteConstantSprite/EnteColormask.modulate.h = $"../../Gui/Settings/ColorSlider".value*0.01
func _on_ente_sprite_frame_changed() -> void:
$EnteConstantSprite/EnteColormask.frame = $EnteConstantSprite.frame