Advertisement
GigaOrts

Untitled

Jun 16th, 2023
850
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.62 KB | None | 0 0
  1. //Вместо этого
  2. static void MovePlayer(char[,] map, ref int pacmanPositionX, ref int pacmanPositionY, ConsoleKeyInfo pressedKey, char border)
  3. {
  4.     switch (pressedKey.Key)
  5.     {
  6.         case ConsoleKey.LeftArrow:
  7.             ChangePosition(map[pacmanPositionY, pacmanPositionX - 1], ref pacmanPositionX, false, border);
  8.             break;
  9.  
  10.         case ConsoleKey.RightArrow:
  11.             ChangePosition(map[pacmanPositionY, pacmanPositionX + 1], ref pacmanPositionX, true, border);
  12.             break;
  13.  
  14.         case ConsoleKey.UpArrow:
  15.             ChangePosition(map[pacmanPositionY - 1, pacmanPositionX], ref pacmanPositionY, false, border);
  16.             break;
  17.  
  18.         case ConsoleKey.DownArrow:
  19.             ChangePosition(map[pacmanPositionY + 1, pacmanPositionX], ref pacmanPositionY, true, border);
  20.             break;
  21.     }
  22. }
  23.  
  24. //Сделайте вот это (Написал примерно, корректируйте под свой код, надеюсь помогло навести на мысли)
  25. static void MovePlayer(char[,] map, ref int pacmanPositionX, ref int pacmanPositionY, ConsoleKeyInfo pressedKey, char border)
  26. {
  27.     switch (pressedKey.Key)
  28.     {
  29.         case ConsoleKey.LeftArrow:
  30.             pacmanPositionX--;
  31.             break;
  32.  
  33.         case ConsoleKey.RightArrow:
  34.             pacmanPositionX++;
  35.             break;
  36.  
  37.         case ConsoleKey.UpArrow:
  38.             pacmanPositionY--;
  39.             break;
  40.  
  41.         case ConsoleKey.DownArrow:
  42.             pacmanPositionY++;
  43.             break;
  44.     }
  45.  
  46.     ChangePosition(map[pacmanPositionY, pacmanPositionX], ref pacmanPositionX, false, border);
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement