Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp28
- {
- class Program
- {
- static void Main(string[] args)
- {
- int helth = 17;
- int maxHealth = 20;
- Healthbar(helth, maxHealth, ConsoleColor.DarkBlue);
- Console.SetCursorPosition(0, 1);
- Console.WriteLine($"У вас сейчас: {100 * helth / maxHealth}% ХП");
- void Healthbar(int valueHp, int maxHp, ConsoleColor color)
- {
- ConsoleColor defaultColor = Console.BackgroundColor;
- string HP = "";
- for (int i = 0; i < valueHp; i++)
- {
- HP += '#';
- }
- Console.SetCursorPosition(0, 0);
- Console.Write('[');
- Console.BackgroundColor = color;
- Console.Write(HP);
- Console.BackgroundColor = defaultColor;
- HP = "";
- for (int i = valueHp; i < maxHp; i++)
- {
- HP += '_';
- }
- Console.Write(HP + ']');
- }
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement