Advertisement
o91leg

Untitled

Mar 31st, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _2_Сshrp_L
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int heath = 5, maxHealth = 10;
  10. int mana = 3, maxMana = 10;
  11.  
  12. while (true)
  13. {
  14. DrawBar(heath, maxHealth, ConsoleColor.Red, 0, '_');
  15. DrawBar(mana, maxMana, ConsoleColor.Blue, 1, '_');
  16.  
  17. Console.SetCursorPosition(0, 5);
  18. Console.Write("Введите число на которое измениться жизни");
  19. heath += Convert.ToInt32(Console.ReadLine());
  20. Console.Write("Введите число на которое измениться мана");
  21. mana += Convert.ToInt32(Console.ReadLine());
  22. Console.ReadKey();
  23. Console.Clear();
  24. }
  25. }
  26. static void DrawBar(int value, int maxValue, ConsoleColor color, int position, char symbol = ' ')
  27. {
  28. ConsoleColor defaultColor = Console.BackgroundColor;
  29. string bar = "";
  30.  
  31. for (int i=0; i < value; i++)
  32. {
  33. bar += symbol;
  34. }
  35.  
  36. Console.SetCursorPosition(0, position);
  37. Console.Write('[');
  38. Console.BackgroundColor = color;
  39. Console.Write(bar);
  40. Console.BackgroundColor = defaultColor;
  41.  
  42. bar = "";
  43.  
  44. for (int i= value; i<maxValue; i++)
  45. {
  46. bar += symbol;
  47. }
  48. Console.Write(bar + ']');
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement