StrategyRPG/Johnmagotchi/Core/InputManager/ButtonPress.cs
2026-08-15 12:07:35 -05:00

37 lines
905 B
C#

using System;
using System.Collections.Generic;
using System.Text;
namespace TibzGame.Core.Inputs
{
public class ButtonPress
{
public bool isPressed = false;
public bool isJustPressed = false;
public bool isJustReleased = false;
public UInt64 heldTime = 0;
public void RegisterButtonPress(bool pressed) {
bool lastState = isPressed;
isPressed = pressed;
if (lastState == isPressed) isJustReleased = isJustPressed = false;
else if (isPressed) isJustPressed = true;
else isJustReleased = true;
if (! isPressed) heldTime = 0;
else heldTime++;
}
public void ClearButtonPresses()
{
isPressed = false;
isJustPressed = false;
isJustReleased = false;
heldTime = 0;
}
}
}