Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class MainClass {
- public static void Main(string[] args) {
- int width = 20, height = 15, x = 4, y = 5, running = 1;
- while (running == 1) {
- Console.SetCursorPosition(0,0);
- for(int row = 0; row < height; ++row) {
- for(int col = 0; col < width; ++col) {
- if (row == y && col == x) {
- Console.Write("@");
- } else {
- Console.Write(".");
- }
- }
- Console.Write("\n");
- }
- ConsoleKeyInfo key = Console.ReadKey();
- switch(key.Key) {
- case ConsoleKey.UpArrow: --y; break;
- case ConsoleKey.LeftArrow: --x; break;
- case ConsoleKey.DownArrow: ++y; break;
- case ConsoleKey.RightArrow:++x; break;
- case ConsoleKey.Escape: running = 0; break;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment