Advertisement
SPavelA

OOPTask2PropertiesDrawPlayer

Oct 22nd, 2024
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | Gaming | 0 0
  1. using System;
  2.  
  3. namespace OOPTask2PropertiesDrawPlayer
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Renderer renderer = new Renderer();
  10.             Player player = new Player(20, 15);
  11.  
  12.             renderer.Draw(player);
  13.         }
  14.     }
  15.  
  16.     class Renderer
  17.     {
  18.         public void Draw(Player player)
  19.         {
  20.             Console.Clear();
  21.             Console.CursorVisible = false;
  22.             Console.SetCursorPosition(player.PositionX, player.PositionY);
  23.             Console.Write(player.Character);
  24.             Console.ReadKey(true);
  25.         }
  26.     }
  27.  
  28.     class Player
  29.     {
  30.         public int PositionX { get; private set; }
  31.         public int PositionY { get; private set; }
  32.         public char Character { get; private set; }
  33.  
  34.         public Player(int positionX, int positionY, char character = '@')
  35.         {
  36.             PositionX = positionX;
  37.             PositionY = positionY;
  38.             Character = character;
  39.         }
  40.     }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement