18 lines
656 B
C#
18 lines
656 B
C#
using Godot;
|
|
|
|
namespace Tutorial1;
|
|
|
|
public partial class Abdullah : Sprite2D {
|
|
private const int AMOUNT = 5;
|
|
private Sprite2D child;
|
|
|
|
public override void _Ready() => child = GetNode<Sprite2D>("Child");
|
|
|
|
public override void _Process(double delta) {
|
|
if (Input.IsKeyPressed(Key.W)) Position += new Vector2(0, -AMOUNT);
|
|
if (Input.IsKeyPressed(Key.S)) Position += new Vector2(0, AMOUNT);
|
|
if (Input.IsKeyPressed(Key.A)) Position += new Vector2(-AMOUNT, 0);
|
|
if (Input.IsKeyPressed(Key.D)) Position += new Vector2(AMOUNT, 0);
|
|
if (Input.IsKeyPressed(Key.Space)) child.GlobalPosition = Vector2.Zero;
|
|
}
|
|
} |