Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Threading;
- public class Program
- {
- public static void Main(string[] args, char text)
- {
- Thread newThread = new Thread(Walking);
- newThread.Start();
- Console.CursorVisible = false;
- bool onProgramm = true;
- byte scoore = 0;
- int positionX = 10;
- int positionY = 5;
- char[] item = { '$', '$', '$' };
- string error;
- string point = "Ы";
- //-создание переменных
- Console.SetCursorPosition(12, 3);
- Console.WriteLine(point);
- Console.SetCursorPosition(positionX, positionY);
- Console.WriteLine(item);
- //-первая прорисовка
- while (onProgramm)
- {
- error = null;
- switch (text)
- {
- case 'd':
- positionX++; break;
- case 'a':
- positionX--; break;
- case 's':
- positionY++; break;
- case 'w':
- positionY--; break;
- default: error = "недопустимая команда"; break;
- }
- //-управление
- if (positionX <= 1)
- {
- positionX = positionX + 1;
- }
- if (positionY <= 0)
- {
- positionY = positionY + 1;
- }
- //-защита выхода за карту
- Console.Clear();
- Console.SetCursorPosition(12, 3);
- Console.WriteLine(point);
- Console.SetCursorPosition(positionX, positionY);
- Console.WriteLine(item);
- //-цикличная прорисовка
- Console.SetCursorPosition(0, 20);
- Console.WriteLine(@"Счёт: " + scoore);
- //счёт
- if (error != null)
- {
- Console.WriteLine(error);
- };
- }
- }
- static void Walking(char text)
- {
- while (true)
- {
- Thread.Sleep(500);
- Console.WriteLine();
- Main(text) = Console.ReadKey().KeyChar;
- return;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement