Advertisement
Guest User

Untitled

a guest
May 9th, 2024
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.29 KB | None | 0 0
  1. using System;
  2. using System.Threading;
  3.  
  4. public class Program
  5. {
  6.     public static void Main(string[] args, char text)
  7.     {
  8.         Thread newThread = new Thread(Walking);
  9.         newThread.Start();
  10.  
  11.  
  12.         Console.CursorVisible = false;
  13.  
  14.         bool onProgramm = true;
  15.  
  16.         byte scoore = 0;
  17.  
  18.         int positionX = 10;
  19.         int positionY = 5;
  20.  
  21.         char[] item = { '$', '$', '$' };
  22.  
  23.         string error;
  24.         string point = "Ы";
  25.         //-создание переменных
  26.  
  27.         Console.SetCursorPosition(12, 3);
  28.         Console.WriteLine(point);
  29.  
  30.         Console.SetCursorPosition(positionX, positionY);
  31.         Console.WriteLine(item);
  32.         //-первая прорисовка
  33.  
  34.  
  35.         while (onProgramm)
  36.         {
  37.  
  38.             error = null;
  39.  
  40.  
  41.  
  42.             switch (text)
  43.             {
  44.                 case 'd':
  45.                     positionX++; break;
  46.  
  47.                 case 'a':
  48.                     positionX--; break;
  49.  
  50.                 case 's':
  51.                     positionY++; break;
  52.  
  53.                 case 'w':
  54.                     positionY--; break;
  55.  
  56.                 default: error = "недопустимая команда"; break;
  57.  
  58.  
  59.             }
  60.             //-управление
  61.  
  62.             if (positionX <= 1)
  63.             {
  64.                 positionX = positionX + 1;
  65.             }
  66.             if (positionY <= 0)
  67.             {
  68.                 positionY = positionY + 1;
  69.             }
  70.             //-защита выхода за карту
  71.  
  72.             Console.Clear();
  73.  
  74.  
  75.             Console.SetCursorPosition(12, 3);
  76.             Console.WriteLine(point);
  77.  
  78.             Console.SetCursorPosition(positionX, positionY);
  79.             Console.WriteLine(item);
  80.             //-цикличная прорисовка
  81.  
  82.             Console.SetCursorPosition(0, 20);
  83.             Console.WriteLine(@"Счёт: " + scoore);
  84.             //счёт
  85.  
  86.             if (error != null)
  87.             {
  88.                 Console.WriteLine(error);
  89.             };
  90.         }
  91.  
  92.  
  93.  
  94.     }
  95.  
  96.     static void Walking(char text)
  97.     {
  98.  
  99.         while (true)
  100.         {
  101.             Thread.Sleep(500);
  102.             Console.WriteLine();
  103.  
  104.  
  105.             Main(text) = Console.ReadKey().KeyChar;
  106.  
  107.             return;
  108.         }
  109.     }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement