mirror of
https://github.com/MaddyThorson/StrawberryBF.git
synced 2025-08-17 05:40:40 +08:00
Replaced SDLApp code in Game, no longer extends it
This commit is contained in:
24
src/Input/Input.bf
Normal file
24
src/Input/Input.bf
Normal file
@ -0,0 +1,24 @@
|
||||
using SDL2;
|
||||
|
||||
namespace Strawberry
|
||||
{
|
||||
static public class Input
|
||||
{
|
||||
static public bool KeyCheck(SDL.Scancode key)
|
||||
{
|
||||
if (Game.KeyboardState == null)
|
||||
return false;
|
||||
return Game.KeyboardState[(int)key];
|
||||
}
|
||||
|
||||
static public bool KeyPressed(SDL.Scancode key)
|
||||
{
|
||||
return KeyCheck(key) && (Game.PreviousKeyboardState == null || !Game.PreviousKeyboardState[(int)key]);
|
||||
}
|
||||
|
||||
static public bool KeyReleased(SDL.Scancode key)
|
||||
{
|
||||
return (Game.PreviousKeyboardState != null && Game.PreviousKeyboardState[(int)key]) && !KeyCheck(key);
|
||||
}
|
||||
}
|
||||
}
|
@ -141,9 +141,9 @@ namespace Strawberry
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (Game.IsKeyDown(PositiveKeycode))
|
||||
if (Input.KeyCheck(PositiveKeycode))
|
||||
{
|
||||
if (Game.IsKeyDown(NegativeKeycode))
|
||||
if (Input.KeyCheck(NegativeKeycode))
|
||||
{
|
||||
switch (OverlapBehavior)
|
||||
{
|
||||
@ -170,7 +170,7 @@ namespace Strawberry
|
||||
value = 1;
|
||||
}
|
||||
}
|
||||
else if (Game.IsKeyDown(NegativeKeycode))
|
||||
else if (Input.KeyCheck(NegativeKeycode))
|
||||
{
|
||||
turned = false;
|
||||
value = -1;
|
||||
|
@ -129,7 +129,7 @@ namespace Strawberry
|
||||
{
|
||||
get
|
||||
{
|
||||
return Game.IsKeyDown(Keycode);
|
||||
return Input.KeyCheck(Keycode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user