summaryrefslogtreecommitdiff
path: root/scripts/Character.cs
blob: e3707f5df89352d76361fc1ceac2f9a3ec9f7c75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using Godot;
using System;

public partial class Character : Actor {

	public override void _Input(InputEvent @event)
	{
		base._Input(@event);

		if (!@event.IsPressed()) return;

		Vector2I offset = Vector2I.Zero;

		if (@event.IsActionPressed("walk-up")) {
			offset += Vector2I.Up;
		}
		if (@event.IsActionPressed("walk-down")) {
			offset += Vector2I.Down;
		}
		if (@event.IsActionPressed("walk-left")) {
			offset += Vector2I.Left;
		}
		if (@event.IsActionPressed("walk-right")) {
			offset += Vector2I.Right;
		}

		if (offset != Vector2I.Zero) {
			Walk(offset);
		}
	}
}