Add new methods to input handler, add RectangleShape2d, modify test game.
This commit is contained in:
25
TestGame/TestPlayer.cs
Normal file
25
TestGame/TestPlayer.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using DaggerFramework;
|
||||
using DaggerFramework.SceneGraph;
|
||||
using DaggerFramework.Utils;
|
||||
|
||||
public class TestPlayer : RectangleShape2d
|
||||
{
|
||||
protected override void OnStart()
|
||||
{
|
||||
base.OnStart();
|
||||
Color = Color.Cyan;
|
||||
}
|
||||
|
||||
protected override void OnUpdate(double dt)
|
||||
{
|
||||
base.OnUpdate(dt);
|
||||
|
||||
var sprinting = Input.IsActionDown("sprint");
|
||||
_speed = sprinting ? 400f : 200f;
|
||||
|
||||
var velocity = Input.GetInputDirection("left", "right", "up", "down") * _speed;
|
||||
Position += velocity * (float)dt;
|
||||
}
|
||||
|
||||
private float _speed = 200f;
|
||||
}
|
||||
Reference in New Issue
Block a user