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

var moving = 0

func _ready():
	playing = true
	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)