-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.cs
20 lines (20 loc) · 895 Bytes
/
Player.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
namespace pac_man
{
internal class Player(Func<(int, int), bool> validatePosition) : Character(validatePosition)
{
public void HandleKeyInput(ConsoleKey key)
{
switch (key)
{
case ConsoleKey.W: UpdateDirection(Directions.UP); break;
case ConsoleKey.A: UpdateDirection(Directions.LEFT); break;
case ConsoleKey.S: UpdateDirection(Directions.DOWN); break;
case ConsoleKey.D: UpdateDirection(Directions.RIGHT); break;
case ConsoleKey.UpArrow: UpdateDirection(Directions.UP); break;
case ConsoleKey.LeftArrow: UpdateDirection(Directions.LEFT); break;
case ConsoleKey.DownArrow: UpdateDirection(Directions.DOWN); break;
case ConsoleKey.RightArrow: UpdateDirection(Directions.RIGHT); break;
}
}
}
}