Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _2_Сshrp_L
- {
- class Program
- {
- static void Main(string[] args)
- {
- int heath = 5, maxHealth = 10;
- int mana = 3, maxMana = 10;
- while (true)
- {
- DrawBar(heath, maxHealth, ConsoleColor.Red, 0, '_');
- DrawBar(mana, maxMana, ConsoleColor.Blue, 1, '_');
- Console.SetCursorPosition(0, 5);
- Console.Write("Введите число на которое измениться жизни");
- heath += Convert.ToInt32(Console.ReadLine());
- Console.Write("Введите число на которое измениться мана");
- mana += Convert.ToInt32(Console.ReadLine());
- Console.ReadKey();
- Console.Clear();
- }
- }
- 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 += symbol;
- }
- Console.Write(bar + ']');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement