freettrpg/scripts/player.gd
Patrick_Pluto 0a6ff7224a Version: 0.0.2
Second major release, minor tweaks, fully dynamic stats, now requires the official contentpack.
2024-06-15 21:56:18 +02:00

28 lines
624 B
GDScript

extends CharacterBody2D
@export var speed = 200
var distanceTo = 0
var active = false
func get_input():
if Input.is_action_pressed("escape"):
get_tree().change_scene_to_file("res://scenes/menu/main.tscn")
var input_direction = Input.get_vector("left", "right", "up", "down")
velocity = input_direction * speed
func _physics_process(delta):
if active:
get_input()
move_and_slide()
var toCalculate = position
distanceTo += position.distance_to(toCalculate)
if distanceTo > 500 and active:
active = false
$camera.enabled = false
get_parent().next()
func start():
$camera.enabled = true
active = true