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 train
- {
- class Program
- {
- static void Main(string[] args)
- {
- int X = 0, Y = 0;
- //у пользователя есть координаты X Y, необходимо сделать так, чтобы при нажатии клавиш WASD
- //происходило изменение координат пользователя и каждую итерацию необходимо выводить эти координаты
- //в консоль
- ConsoleKey playerKey = Console.ReadKey(true).Key;
- while (playerKey != ConsoleKey.Escape)
- {
- playerKey = Console.ReadKey(true).Key;
- if (playerKey == ConsoleKey.D)
- {
- X++;
- }
- playerKey = Console.ReadKey(true).Key;
- if (playerKey == ConsoleKey.A)
- {
- X--;
- }
- playerKey = Console.ReadKey(true).Key;
- if (playerKey == ConsoleKey.W)
- {
- Y++;
- }
- playerKey = Console.ReadKey(true).Key;
- if (playerKey == ConsoleKey.S)
- {
- Y--;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement