Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int health = 0, maxHealth = 10;
- int mana = 0, maxMana = 10;
- bool isOpen = true;
- while (isOpen)
- {
- Console.WriteLine("Введите количество жизней");
- health = Convert.ToInt32(Console.ReadLine());
- if(health.ToString() == "")
- {
- break;
- }
- Console.WriteLine("Введите количество маны");
- mana = Convert.ToInt32(Console.ReadLine());
- DrawBar(health, maxHealth, ConsoleColor.Red, 5, '#');
- Console.Write(" <- Жизни");
- DrawBar(mana, maxMana, ConsoleColor.Blue, 7, '*');
- Console.Write(" <- Мана\n");
- Console.WriteLine("\nДля выхода введите любой символ");
- if(Console.ReadLine() != "")
- {
- isOpen = false;
- }
- Console.Clear();
- }
- }
- private static void DrawBar(int value, int maxValue, ConsoleColor color, int position, char symbol = '_')
- {
- ConsoleColor defaultColor = Console.BackgroundColor;
- string bar = "";
- for (int i = 0; i < value; i++)
- {
- bar += symbol;
- }
- Console.SetCursorPosition(0, position);
- Console.Write("[");
- Console.BackgroundColor = color;
- Console.Write(bar);
- Console.BackgroundColor = defaultColor;
- bar = "";
- for (int i = value; i < maxValue; i++)
- {
- bar += '_';
- }
- Console.Write(bar + "]");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement