-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKey.cs
39 lines (33 loc) · 819 Bytes
/
Key.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
using Microsoft.Xna.Framework.Input;
namespace ConwaysGameOfLife
{
/// <summary>
/// Tracks the input from a key on the user's keyboard.
/// Created by: Ethan Genser
/// </summary>
public class Key
{
#region _Variables_
private Keys key;
private bool down;
public bool pressed { get; private set; }
#endregion
// Constructor
public Key(Keys key)
{
this.key = key;
}
public void Update()
{
if (Keyboard.GetState().IsKeyDown(key))
down = true;
if (Keyboard.GetState().IsKeyUp(key) && down)
{
down = false;
pressed = true;
}
else
pressed = false;
}
}
}