2024-11-01 18:15:44 +01:00
|
|
|
extends Node2D
|
|
|
|
|
|
2024-11-02 07:24:48 +01:00
|
|
|
@onready var player: CharacterBody2D = $Player
|
|
|
|
|
@onready var start_position: Marker2D = $StartPosition
|
|
|
|
|
|
2024-11-16 23:26:08 +01:00
|
|
|
func _ready() -> void:
|
|
|
|
|
var traps = get_tree().get_nodes_in_group("traps")
|
|
|
|
|
|
|
|
|
|
for trap in traps:
|
|
|
|
|
if trap is Trap:
|
|
|
|
|
trap.touched_player.connect(_on_trap_touched_player)
|
|
|
|
|
|
2024-11-01 18:15:44 +01:00
|
|
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
|
|
|
func _process(delta: float) -> void:
|
|
|
|
|
if Input.is_action_just_pressed("quit"):
|
|
|
|
|
get_tree().quit()
|
|
|
|
|
elif Input.is_action_just_pressed("reset"):
|
|
|
|
|
get_tree().reload_current_scene()
|
2024-11-02 07:24:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
func _on_death_zone_body_entered(body: Node2D) -> void:
|
2024-11-02 08:07:54 +01:00
|
|
|
reset_player()
|
|
|
|
|
pass # Replace with function body.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _on_trap_touched_player() -> void:
|
|
|
|
|
reset_player()
|
|
|
|
|
pass # Replace with function body.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func reset_player() -> void:
|
2024-11-02 07:24:48 +01:00
|
|
|
player.velocity = Vector2.ZERO
|
|
|
|
|
player.global_position = start_position.global_position
|
2024-11-02 08:07:54 +01:00
|
|
|
pass
|