Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Lesson8
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.CursorVisible = false;
- char[,] map =
- {
- { '#','#','#','#','#','#','#','#','#','#'},
- { '#','#','#','#',' ',' ',' ',' ','X','#'},
- { '#','X',' ',' ',' ','#','#','#',' ','#'},
- { '#',' ',' ','#','#','X',' ',' ',' ','#'},
- { '#',' ',' ',' ','#',' ','#','#','#','#'},
- { '#','#','#',' ','#',' ',' ',' ',' ','#'},
- { '#',' ',' ',' ','#',' ','#','#',' ','#'},
- { '#',' ','#','#','#',' ','X','#',' ','#'},
- { '#',' ',' ',' ','#','#',' ','#',' ','#'},
- { '#','X','#','X',' ',' ',' ','#',' ','#'},
- { '#','#','#','#','#','#','#','#','#','#'}
- };
- char[] bag = new char[0];
- int userX = 3, userY = 3;
- bool exit = false;
- while (!exit)
- {
- Console.SetCursorPosition(20, 0);
- Console.Write("Сумка: ");
- for (int i = 0; i < bag.Length; i++)
- Console.Write(bag[i] + " | ");
- Console.SetCursorPosition(0, 0);
- for (int i = 0; i < map.GetLength(0); i++)
- {
- for (int j = 0; j < map.GetLength(1); j++)
- {
- Console.Write(map[i, j]);
- }
- Console.WriteLine();
- }
- Console.SetCursorPosition(userY, userX);
- Console.Write('@');
- ConsoleKeyInfo charKey = Console.ReadKey();
- switch (charKey.Key)
- {
- case ConsoleKey.UpArrow:
- if (map[userX - 1, userY] != '#')
- userX--;
- break;
- case ConsoleKey.DownArrow:
- if (map[userX + 1, userY] != '#')
- userX++;
- break;
- case ConsoleKey.LeftArrow:
- if (map[userX, userY - 1] != '#')
- userY--;
- break;
- case ConsoleKey.RightArrow:
- if (map[userX, userY + 1] != '#')
- userY++;
- break;
- }
- //проверка на колво призов и открытие ворот
- if (bag.Length >= 6)
- map[9,9] = 'П';
- if (map[userX, userY] == 'X')
- {
- map[userX, userY] = 'o';
- char[] tempBag = new char[bag.Length + 1];
- for (int i = 0; i < bag.Length; i++)
- {
- tempBag[i] = bag[i];
- }
- tempBag[tempBag.Length - 1] = 'X';
- bag = tempBag;
- }
- else if (map[userX, userY] == 'П')
- {
- exit = true;
- }
- }
- Console.Clear();
- Console.WriteLine("Поздравляю Вы выграли!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement