Initial commit
This commit is contained in:
38
scripts/InputHandler.cs
Normal file
38
scripts/InputHandler.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user