Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace C_Sharp_Junior
- {
- class Program
- {
- static void Main(string[] args)
- {
- int health = 5;
- while (health > 0)
- {
- DrawBar("Жизни | ", health);
- Console.SetCursorPosition(0, 3);
- Console.Write("Сколько у вас жизни:");
- health = Convert.ToInt32(Console.ReadLine());
- Console.Clear();
- }
- Console.WriteLine("Вы мертвы.");
- Console.ReadKey();
- }
- static void DrawBar(string text, int health)
- {
- int maxPercent = 100;
- int percent = maxPercent * health / 100;
- string bar = "";
- for (int i = 0; i < percent && i < maxPercent; i++)
- {
- bar += "#";
- }
- Console.Write($"{text} [ {bar}");
- bar = "";
- for (int i = percent; i < maxPercent; i++)
- {
- bar += "_";
- }
- Console.Write($"{bar}]");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement