kisame1313

Untitled

Jul 12th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace Task_1_3_5
  6.     {
  7.     class Program
  8.         {
  9.         static void Main()
  10.             {
  11.  
  12.             int currentPositionX = 0;
  13.             int currentPositionY = 0;
  14.  
  15.             while(true)
  16.              {
  17.                      
  18.                 ConsoleKey input = Console.ReadKey(true).Key;
  19.                 Console.Clear();
  20.                 Console.WriteLine("x {0}, y{1}",currentPositionX,currentPositionY);
  21.  
  22.                 if(input == ConsoleKey.A)
  23.                     {
  24.                     currentPositionX--;
  25.                     }
  26.                 else if(input == ConsoleKey.W)
  27.                     {
  28.                     currentPositionY++;
  29.                     }
  30.                 else if(input == ConsoleKey.D)
  31.                     {
  32.                     currentPositionX++;
  33.                     }
  34.                 else if(input == ConsoleKey.S)
  35.                     {
  36.                     currentPositionY--;
  37.                     }
  38.                 else if(input == ConsoleKey.Escape)
  39.                     {
  40.                     break;
  41.                     }
  42.                 }
  43.             }
  44.         }
  45.     }
Advertisement
Add Comment
Please, Sign In to add comment