2024-10-01 15:56:30 +02:00
|
|
|
extends CharacterBody2D
|
|
|
|
|
|
|
|
|
|
|
|
const JUMP_VELOCITY = -230.0
|
|
|
|
signal gameover
|
|
|
|
|
|
|
|
@onready var alive = true
|
2024-10-03 21:12:20 +02:00
|
|
|
var state = "main-menu"
|
2024-10-01 15:56:30 +02:00
|
|
|
|
|
|
|
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()
|
2024-10-03 21:12:20 +02:00
|
|
|
|
|
|
|
if $"/root/Global".gamerunning:
|
|
|
|
state = "game"
|
|
|
|
|
|
|
|
if state == "main-menu" :
|
2024-10-01 15:56:30 +02:00
|
|
|
$AnimationPlayer.play("idle")
|
2024-10-03 21:12:20 +02:00
|
|
|
elif state == "game":
|
|
|
|
if not is_on_floor():
|
|
|
|
$AnimationPlayer.play("fly")
|
|
|
|
elif not alive:
|
|
|
|
$AnimationPlayer.play("die")
|
|
|
|
else:
|
|
|
|
$AnimationPlayer.play("walk")
|
2024-10-01 15:56:30 +02:00
|
|
|
|
|
|
|
func _collide_with_hindernis(_body: Node2D) -> void:
|
|
|
|
print("colide")
|
|
|
|
if alive:
|
|
|
|
die()
|
2024-10-03 21:12:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
func _color_slider_changed(value) -> void:
|
|
|
|
print($"../../Gui/Settings/ColorSlider".value*0.01)
|
2024-10-07 17:02:32 +02:00
|
|
|
$EnteConstantSprite/EnteColormask.modulate.h = $"../../Gui/Settings/ColorSlider".value*0.01
|
2024-10-03 21:12:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
func _on_ente_sprite_frame_changed() -> void:
|
2024-10-07 17:02:32 +02:00
|
|
|
$EnteConstantSprite/EnteColormask.frame = $EnteConstantSprite.frame
|