This repository has been archived on 2023-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
dungeon-crawler-demo/scripts/InputHandler.cs
2020-10-26 00:50:16 -04:00

38 lines
921 B
C#

using Godot;
/// <summary>Class <c>InputHandler</c> holds static methods
/// for handling player input.</summary>
public static class InputHandler
{
/// <summary>method <c>MovementInput</c> returns a Vector2 based on player input.</summary>
public static Vector2 MovementInput()
{
Vector2 movement = new Vector2();
if(Input.IsActionJustPressed("move_up"))
{
movement.y -= 1;
}
if(Input.IsActionJustPressed("move_down"))
{
movement.y += 1;
}
if(Input.IsActionJustPressed("move_right"))
{
movement.x += 1;
}
if(Input.IsActionJustPressed("move_left"))
{
movement.x -= 1;
}
return movement;
}
/// <summary>method <c>DebugKeyInput</c> returns bool when debug key is pressed in a debug build.</summary>
public static bool DebugKeyInput()
{
if(OS.IsDebugBuild())
return Input.IsActionJustPressed("debug_general");
return false;
}
}