Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace les220072017
- {
- class Program
- {
- static void Main(string[] args)
- {
- Enemy vrag1 = new Enemy(1, 1, '#', ConsoleColor.Red);
- vrag1.Move(2);
- vrag1.Show();
- }
- }
- class Enemy
- {
- public int X;
- public int Y;
- public char Visual;
- public ConsoleColor Color;
- public Enemy(int x, int y, char visual, ConsoleColor color)
- {
- X = x;
- Y = y;
- Visual = visual;
- Color = color;
- }
- public void Move(int direction)
- {
- switch (direction)
- {
- case 1:
- Y -= 1;
- break;
- case 2:
- X += 1;
- break;
- case 3:
- Y += 1;
- break;
- case 4:
- X -= 1;
- break;
- }
- }
- public void Show()
- {
- ConsoleColor temp = Console.ForegroundColor;
- Console.ForegroundColor = Color;
- Console.SetCursorPosition(X, Y);
- Console.Write(Visual);
- Console.ForegroundColor = temp;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement