Add new methods to input handler, add RectangleShape2d, modify test game.
This commit is contained in:
@@ -26,6 +26,23 @@ namespace DaggerFramework
|
||||
return dir == Vector2.Zero ? Vector2.Zero : Vector2.Normalize(dir);
|
||||
}
|
||||
|
||||
public override Vector2 GetInputDirection(string leftAction, string rightAction, string upAction, string downAction)
|
||||
{
|
||||
Vector2 dir = Vector2.Zero;
|
||||
|
||||
if (IsActionDown(leftAction))
|
||||
dir += new Vector2(-1, 0);
|
||||
if (IsActionDown(rightAction))
|
||||
dir += new Vector2(1, 0);
|
||||
if (IsActionDown(upAction))
|
||||
dir += new Vector2(0, -1);
|
||||
if (IsActionDown(downAction))
|
||||
dir += new Vector2(0, 1);
|
||||
|
||||
|
||||
return dir == Vector2.Zero ? Vector2.Zero : Vector2.Normalize(dir);
|
||||
}
|
||||
|
||||
public override Vector2 GetMousePosition()
|
||||
{
|
||||
return Raylib.GetMousePosition();
|
||||
@@ -43,18 +60,39 @@ namespace DaggerFramework
|
||||
|
||||
public override bool IsActionDown(string action)
|
||||
{
|
||||
// throw new NotImplementedException();
|
||||
// return inputMappings[action].IsPressed();
|
||||
foreach (InputAction inputAction in inputMappings[action])
|
||||
if (inputAction.IsDown(this)) return true;
|
||||
IEnumerable<InputAction>? mappings;
|
||||
|
||||
if (TryGetInputMappings(action, out mappings))
|
||||
{
|
||||
foreach (InputAction inputAction in mappings)
|
||||
if (inputAction.IsDown(this)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool IsActionJustPressed(string action)
|
||||
public override bool IsActionPressed(string action)
|
||||
{
|
||||
foreach (InputAction inputAction in inputMappings[action])
|
||||
if (inputAction.IsPressed(this)) return true;
|
||||
IEnumerable<InputAction>? mappings;
|
||||
|
||||
if (TryGetInputMappings(action, out mappings))
|
||||
{
|
||||
foreach (InputAction inputAction in mappings)
|
||||
if (inputAction.IsPressed(this)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool IsActionReleased(string action)
|
||||
{
|
||||
IEnumerable<InputAction>? mappings;
|
||||
|
||||
if (TryGetInputMappings(action, out mappings))
|
||||
{
|
||||
foreach (InputAction inputAction in mappings)
|
||||
if (inputAction.IsReleased(this)) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -77,6 +115,11 @@ namespace DaggerFramework
|
||||
return Raylib.IsKeyPressed(rayKey);
|
||||
}
|
||||
|
||||
public override bool KeyboardKeyJustReleased(KeyboardKey key)
|
||||
{
|
||||
return Raylib.IsKeyReleased((Raylib_cs.KeyboardKey)key);
|
||||
}
|
||||
|
||||
public override void SetMousePosition(Vector2 position)
|
||||
{
|
||||
Raylib.SetMousePosition((int)position.X, (int)position.Y);
|
||||
|
||||
Reference in New Issue
Block a user