Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class program
- {
- static void Main(string[] args)
- {
- char[] chars = {'#', '_'};
- Console.Write("Введите размер строки жизней:");
- int sizeHealthbar = Convert.ToInt32(Console.ReadLine());
- Console.Write("Введите процент заполнения строки жизней:");
- int percentHealthbar = Convert.ToInt32(Console.ReadLine());
- Console.Write("Введите размер строки маны:");
- int sizeManabar = Convert.ToInt32(Console.ReadLine());
- Console.Write("Введите процент заполнения строки маны:");
- int percentManabar = Convert.ToInt32(Console.ReadLine());
- Console.Clear();
- DrawBar(sizeHealthbar, percentHealthbar, chars[0], chars[1], 0);
- DrawBar(sizeManabar, percentManabar, chars[0], chars[1], 1);
- }
- static void DrawBar(int size, int percent, char symbolGrid, char symbolBottomDash, int position)
- {
- int divider = 100;
- int zero = 0;
- int transferPercentBar = (size * percent) / divider;
- string bar = "";
- FillingBar(zero, transferPercentBar, ref bar, symbolGrid);
- Console.SetCursorPosition(0, position);
- Console.Write('[');
- Console.Write(bar);
- bar = "";
- FillingBar(transferPercentBar, size, ref bar, symbolBottomDash);
- Console.Write(bar + ']');
- }
- static void FillingBar(int startPoint, int outPoint, ref string whiteSpace, char symbol)
- {
- for (int i = startPoint; i < outPoint; i++)
- {
- whiteSpace += symbol;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement