Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Brave_new_world
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.CursorVisible = false;
- char[,] map =
- {
- {'#','#','#','#','#','#','#','#','#','#','#','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ','#' },
- {'#','#','#','#','#','#','#','#','#','#','#','#' }
- };
- int userY = 1, userX = 1;
- char[] bag = new char[0];
- while (true)
- {
- 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;
- case ConsoleKey.Enter:
- map[userX, userY] = '#';
- break;
- case ConsoleKey.Backspace:
- map[userX + 1, userY] = ' ';
- map[userX - 1, userY] = ' ';
- map[userX, userY + 1] = ' ';
- map[userX, userY - 1] = ' ';
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement