Ziomnexpl

k*rwa działa C#

Dec 2nd, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.73 KB | None | 0 0
  1. using System;
  2.  
  3. namespace x
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int x = 1;
  10.             int y = 1;
  11.             int w;
  12.             int h;          
  13.             do
  14.             {
  15.                 w = Console.WindowWidth;
  16.                 h = Console.WindowHeight;
  17.                 Console.CursorVisible = false;
  18.                 if (Console.ReadKey().Key == ConsoleKey.RightArrow)
  19.                 {
  20.                     Console.Clear();
  21.                     x = x + 1;
  22.                     if (x == w) x = 1; //dziala
  23.                     Console.SetCursorPosition(x, y);
  24.                     Console.Write("x");
  25.                 }
  26.                 if (Console.ReadKey().Key == ConsoleKey.LeftArrow)
  27.                 {
  28.                     Console.Clear();
  29.                     x = x - 1;
  30.                     if (x <= 0) x = x + w - 1;
  31.                     Console.SetCursorPosition(x, y);                
  32.                     Console.Write("x");                    
  33.                 }
  34.                 if (Console.ReadKey().Key == ConsoleKey.UpArrow)
  35.                 {
  36.                     Console.Clear();
  37.                     y = y - 1;
  38.                     if (y <= 0) y = y + h - 1;
  39.                     Console.SetCursorPosition(x, y);
  40.                     Console.Write("x");
  41.                 }
  42.                 if (Console.ReadKey().Key == ConsoleKey.DownArrow)
  43.                 {
  44.                     Console.Clear();
  45.                     y = y + 1;
  46.                     if (y == h) y = 1; //dziala
  47.                     Console.SetCursorPosition(x, y);
  48.                     Console.Write("x");
  49.                 }
  50.             } while (Console.ReadKey().Key != ConsoleKey.Escape);
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment