SHOW:
|
|
- or go back to the newest paste.
1 | using System; | |
2 | ||
3 | namespace C_sharp_Light | |
4 | { | |
5 | class Program | |
6 | { | |
7 | static void Main(string[] args) | |
8 | { | |
9 | - | |
9 | + | RenderEntity renderEntity = new RenderEntity(); |
10 | Player player = new Player(5, 5, '@'); | |
11 | renderEntity.Draw(player); | |
12 | Console.ReadKey(); | |
13 | } | |
14 | } | |
15 | ||
16 | class Player | |
17 | { | |
18 | private int _x; | |
19 | private int _y; | |
20 | public int X | |
21 | { | |
22 | get | |
23 | { | |
24 | return _x; | |
25 | } | |
26 | set | |
27 | { | |
28 | if (value < 0) | |
29 | value = 0; | |
30 | _x = value; | |
31 | } | |
32 | } | |
33 | public int Y | |
34 | { | |
35 | get | |
36 | { | |
37 | return _y; | |
38 | } | |
39 | set | |
40 | { | |
41 | if (value < 0) | |
42 | value = 0; | |
43 | _y = value; | |
44 | } | |
45 | } | |
46 | public char SymbolPlayer { get; private set; } | |
47 | ||
48 | public Player(int x, int y, char charPlayer) | |
49 | { | |
50 | X = x; | |
51 | Y = y; | |
52 | SymbolPlayer = charPlayer; | |
53 | } | |
54 | ||
55 | } | |
56 | ||
57 | class RenderEntity | |
58 | { | |
59 | public void Draw(Player player) | |
60 | { | |
61 | Console.SetCursorPosition(player.X, player.Y); | |
62 | Console.Write(player.SymbolPlayer); | |
63 | } | |
64 | } | |
65 | } |