extends CharacterBody2D

var remote_player :bool= false

var max_walk :float= 10
var accel_walk :float= 100

var max_run :float= 20
var accel_run :float= 2 * accel_walk

var friction_tonic :float= 1e-1

var move_dir :Vector2= Vector2.ZERO

# Called when the node enters the scene tree for the first time.
func _ready():
	$PlayerSprite.play("still")

func set_move_direction(dir):
	move_dir = dir

func move_player(delta):
	position.x += move_dir.x * max_walk
	position.y += move_dir.y * max_walk

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	move_player(delta)

func _input(event):
	if remote_player:
		pass
	var direction :Vector2= move_dir
	if event.is_action_released("player_up"):
		if direction.y < 0:
			direction.y = 0
	elif event.is_action_pressed("player_up"):
		direction.y = -1
	if event.is_action_released("player_down"):
		if direction.y > 0:
			direction.y = 0
	elif event.is_action_pressed("player_down"):
		direction.y = 1
		
	if event.is_action_released("player_left"):
		if direction.x < 0:
			direction.x = 0
	elif event.is_action_pressed("player_left"):
		direction.x = -1
	if event.is_action_released("player_right"):
		if direction.x > 0:
			direction.x = 0
	elif event.is_action_pressed("player_right"):
		direction.x = 1
	direction = direction.normalized()

	set_move_direction(direction)
