-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInputHandler.cs
52 lines (47 loc) · 1.01 KB
/
InputHandler.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace SnakeMess
{
public class InputHandler
{
private static readonly InputHandler instance = new InputHandler();
public static InputHandler Instance{
get
{
return instance;
}
}
private ConsoleKeyInfo input;
public void UpdateInput()
{
input = Console.ReadKey(true);
}
public bool Escape()
{
return input.Key == ConsoleKey.Escape;
}
public bool Space()
{
return input.Key == ConsoleKey.Spacebar;
}
public bool Left()
{
return input.Key == ConsoleKey.LeftArrow;
}
public bool Right()
{
return input.Key == ConsoleKey.RightArrow;
}
public bool Up()
{
return input.Key == ConsoleKey.UpArrow;
}
public bool Down()
{
return input.Key == ConsoleKey.DownArrow;
}
}
}