Move about the GoDot geezers boat race
This commit is contained in:
31
Player.cs
Normal file
31
Player.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Godot;
|
||||
|
||||
public partial class Player : Sprite2D
|
||||
{
|
||||
// Speed in pixels per second
|
||||
private float _speed = 400.0f;
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
Vector2 velocity = Vector2.Zero;
|
||||
|
||||
if (Input.IsActionPressed("ui_right"))
|
||||
{
|
||||
velocity.X += 1.0f;
|
||||
}
|
||||
if (Input.IsActionPressed("ui_left"))
|
||||
{
|
||||
velocity.X -= 1.0f;
|
||||
}
|
||||
if (Input.IsActionPressed("ui_down"))
|
||||
{
|
||||
velocity.Y += 1.0f;
|
||||
}
|
||||
if (Input.IsActionPressed("ui_up"))
|
||||
{
|
||||
velocity.Y -= 1.0f;
|
||||
}
|
||||
|
||||
Position += velocity * _speed * (float)delta;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user