48 lines
1.1 KiB
C#
48 lines
1.1 KiB
C#
using System;
|
|||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Text;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
using Microsoft.Xna.Framework.Input;
|
||
|
|
|
||
|
|
|
||
|
|
namespace EvilSatellites
|
||
|
|
{
|
||
|
|
public class InputManager
|
||
|
|
{
|
||
|
|
private KeyboardState OldKeyState;
|
||
|
|
private KeyboardState NewKeyState;
|
||
|
|
public InputManager()
|
||
|
|
{
|
||
|
|
OldKeyState = Keyboard.GetState();
|
||
|
|
NewKeyState = Keyboard.GetState();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void Update()
|
||
|
|
{
|
||
|
|
OldKeyState = NewKeyState;
|
||
|
|
NewKeyState = Keyboard.GetState();
|
||
|
|
}
|
||
|
|
|
||
|
|
public bool IsJustPressed(Keys key)
|
||
|
|
{
|
||
|
|
return (NewKeyState.IsKeyDown(key) && !OldKeyState.IsKeyDown(key));
|
||
|
|
}
|
||
|
|
|
||
|
|
public bool IsJustReleased(Keys key)
|
||
|
|
{
|
||
|
|
return !NewKeyState.IsKeyDown(key) && OldKeyState.IsKeyDown(key);
|
||
|
|
}
|
||
|
|
|
||
|
|
public bool IsPressed(Keys key)
|
||
|
|
{
|
||
|
|
return NewKeyState.IsKeyDown(key);
|
||
|
|
}
|
||
|
|
|
||
|
|
public bool IsReleased(Keys key)
|
||
|
|
{
|
||
|
|
return NewKeyState.IsKeyUp(key);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|