summaryrefslogtreecommitdiff
path: root/Character.gd
blob: ab2257425868eed9eba2e467d4c28862e1e4a3fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
extends AnimatedSprite2D

var moving = 0

func _ready():
	play()
	animation = "idle"

func _process(delta):
	if (Input.is_key_pressed(KEY_LEFT)):
		moving = -1
	elif (Input.is_key_pressed(KEY_RIGHT)):
		moving = 1
	else:
		moving = 0
	
	if (moving == 0):
		animation = "idle"
	else:
		animation = "run"
		scale = Vector2(moving, 1) * Vector2(abs(scale.x), scale.y)
		position += Vector2(moving * 200 * delta, 0)