2024-06-13 13:29:05 +02:00
|
|
|
extends CharacterBody2D
|
|
|
|
|
|
|
|
@export var speed = 200
|
2024-06-13 14:25:37 +02:00
|
|
|
var distanceTo = 0
|
|
|
|
var active = false
|
2024-06-13 13:29:05 +02:00
|
|
|
|
|
|
|
func get_input():
|
2024-06-15 20:33:37 +02:00
|
|
|
if Input.is_action_pressed("escape"):
|
|
|
|
get_tree().change_scene_to_file("res://scenes/menu/main.tscn")
|
2024-06-13 13:29:05 +02:00
|
|
|
var input_direction = Input.get_vector("left", "right", "up", "down")
|
|
|
|
velocity = input_direction * speed
|
|
|
|
|
|
|
|
func _physics_process(delta):
|
2024-06-16 00:01:13 +02:00
|
|
|
var toCalculate = position
|
2024-06-13 14:25:37 +02:00
|
|
|
if active:
|
|
|
|
get_input()
|
|
|
|
move_and_slide()
|
2024-06-15 21:56:18 +02:00
|
|
|
distanceTo += position.distance_to(toCalculate)
|
2024-06-16 00:01:13 +02:00
|
|
|
print(distanceTo)
|
2024-06-13 14:25:37 +02:00
|
|
|
if distanceTo > 500 and active:
|
|
|
|
active = false
|
|
|
|
$camera.enabled = false
|
2024-06-16 00:01:13 +02:00
|
|
|
distanceTo = 0
|
2024-06-13 14:25:37 +02:00
|
|
|
get_parent().next()
|
|
|
|
|
|
|
|
|
|
|
|
func start():
|
|
|
|
$camera.enabled = true
|
|
|
|
active = true
|
2024-06-14 09:42:54 +02:00
|
|
|
|