Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace les220072017
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Enemy vrag1 = new Enemy(1, 1, '#', ConsoleColor.Red);
  14. vrag1.Move(2);
  15. vrag1.Show();
  16. }
  17. }
  18.  
  19. class Enemy
  20. {
  21. public int X;
  22. public int Y;
  23. public char Visual;
  24. public ConsoleColor Color;
  25.  
  26. public Enemy(int x, int y, char visual, ConsoleColor color)
  27. {
  28. X = x;
  29. Y = y;
  30. Visual = visual;
  31. Color = color;
  32. }
  33.  
  34. public void Move(int direction)
  35. {
  36. switch (direction)
  37. {
  38. case 1:
  39. Y -= 1;
  40. break;
  41. case 2:
  42. X += 1;
  43. break;
  44. case 3:
  45. Y += 1;
  46. break;
  47. case 4:
  48. X -= 1;
  49. break;
  50. }
  51. }
  52.  
  53. public void Show()
  54. {
  55. ConsoleColor temp = Console.ForegroundColor;
  56. Console.ForegroundColor = Color;
  57. Console.SetCursorPosition(X, Y);
  58. Console.Write(Visual);
  59. Console.ForegroundColor = temp;
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement