Benjail

5.3

Sep 10th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.68 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Risovanie
  4. {
  5.     class Player
  6.     {
  7.       public int Y { get; private set;}
  8.       public int X { get; private set; }
  9.       public string strplayer;
  10.         public Player(string player)                          
  11.         {
  12.             strplayer=player;
  13.             Y = 0;
  14.             X = 0;
  15.         }
  16.         public void drawplayer()
  17.         {
  18.             Console.Write("Установите координаты для рисования\nX:"); //для интереса предоставил выбор координат внутри метода
  19.             X=Convert.ToInt32(Console.ReadLine());  
  20.             Console.Write("Y: ");                      
  21.             Y = Convert.ToInt32(Console.ReadLine());  
  22.             string[] array = strplayer.Split("\n"); //разбиваем строку игрока на массив элементов
  23.             for (int i=0;i<array.Length;i++)        
  24.             {                                        
  25.                 Console.SetCursorPosition(X, Y+i);    
  26.                 Console.Write(array[i]);              
  27.             }          
  28.         }
  29.     }
  30.     class Program
  31.     {
  32.         static void Main(string[] args)
  33.         {
  34.             bool open = true;
  35.             while (open)
  36.             {                                                
  37.                 Console.WriteLine("Нарисуйте игрока где хотите");
  38.                 Player player1 = new Player("\\___/" + "\n|*_*|\n_____\n  |\n_____\n/    \\\n");
  39.                 player1.drawplayer();
  40.                 Console.ReadKey();
  41.                 Console.Clear();
  42.             }
  43.                      
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment