Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class PlayerController
- {
- public int Controller()
- {
- Map map = new Map();
- Player player = new Player();
- ConsoleKeyInfo consoleKey = Console.ReadKey();
- {
- switch (consoleKey.Key)
- {
- case ConsoleKey.LeftArrow:
- if (map.Level[player.PlayerPositionX, player.PlayerPositionY - 1] != '#')
- {
- return player.PlayerPositionY--;
- }
- break;
- case ConsoleKey.RightArrow:
- if (map.Level[player.PlayerPositionX, player.PlayerPositionY + 1] != '#')
- {
- return player.PlayerPositionY++;
- }
- break;
- case ConsoleKey.UpArrow:
- if (map.Level[player.PlayerPositionX - 1, player.PlayerPositionY] != '#')
- {
- return player.PlayerPositionX--;
- }
- break;
- case ConsoleKey.DownArrow:
- if (map.Level[player.PlayerPositionX + 1, player.PlayerPositionY] != '#')
- {
- return player.PlayerPositionX++;
- }
- break;
- }
- }
- }
- static bool TryKey(ConsoleKeyInfo consoleKey)
- {
- if (consoleKey.Key = ConsoleKey.LeftArrow || consoleKey.Key = ConsoleKey.RightArrow || consoleKey.Key = ConsoleKey.UpArrow || consoleKey.Key = ConsoleKey.DownArrow)
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement