Advertisement
levamurashev2002

Untitled

Jul 14th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CsLight
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. Console.CursorVisible = false;
  10.  
  11. char[,] map =
  12. {
  13. {'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#', },
  14. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#', },
  15. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#', },
  16. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#', },
  17. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#', },
  18. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#', },
  19. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#', },
  20. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#', },
  21. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#', },
  22. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#', },
  23. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#', },
  24. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#', },
  25. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#', },
  26. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#', },
  27. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#', },
  28. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#', },
  29. {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#', },
  30. {'#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#','#', }
  31. };
  32.  
  33. int userY = 1, userX = 1;
  34. char[] bag = new char[0];
  35.  
  36.  
  37. {
  38. Console.SetCursorPosition(20, 0);
  39. Console.Write("Сумка: ");
  40. for (int i = 0; i < bag.Length; i++)
  41. Console.Write(bag[i] + " | ");
  42. Console.SetCursorPosition(0, 0);
  43. for (int i = 0; i < map.GetLength(0); i++)
  44. {
  45. for (int j = 0; j < map.GetLength(1); j++)
  46. {
  47. Console.Write(map[i, j]);
  48. }
  49. Console.WriteLine();
  50. }
  51.  
  52. Console.SetCursorPosition(userY, userX);
  53. Console.Write('@');
  54. ConsoleKeyInfo charKey = Console.ReadKey();
  55.  
  56. switch (charKey.Key)
  57. {
  58. case ConsoleKey.UpArrow:
  59. if (map[userX - 1, userY] != '#')
  60. userX--;
  61. break;
  62. case ConsoleKey.DownArrow:
  63. if (map[userX + 1, userY] != '#')
  64. userX++;
  65. break;
  66. case ConsoleKey.LeftArrow:
  67. if (map[userX, userY - 1] != '#')
  68. userY--;
  69. break;
  70. case ConsoleKey.RightArrow:
  71. if (map[userX, userY + 1] != '#')
  72. userY++;
  73. break;
  74. }
  75.  
  76. if (map[userX, userY] == 'X')
  77. {
  78. map[userX, userY] = 'O';
  79.  
  80. char[] tempBag = new char[bag.Length + 1];
  81.  
  82. for (int i = 0; i < bag.Length; i++)
  83. {
  84. tempBag[i] = bag[i];
  85. }
  86. tempBag[tempBag.Length - 1] = 'X';
  87. bag = tempBag;
  88. }
  89. }
  90. }
  91. }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement