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 ConsoleApp3
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Укажите позицию Х в которой хотите нарисовать bar");
- int positionY = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Укажите позицию У в которой хотите нарисовать bar");
- int positionX = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Укажите значение для закрашивания");
- int health = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Укажите максимальное значение бара");
- int maxHealth = Convert.ToInt32(Console.ReadLine());
- Console.Clear();
- DrawBar(health, maxHealth, ConsoleColor.Red, positionY, positionX);
- }
- static void DrawBar(int value, int maxValue, ConsoleColor color, int positionY, int positionX)
- {
- ConsoleColor defaultColor = Console.BackgroundColor;
- string bar = "";
- for (int i = 0; i < value; i++)
- {
- bar += '_';
- }
- Console.SetCursorPosition(positionY, positionX);
- Console.Write("[");
- Console.BackgroundColor = color;
- Console.Write(bar);
- Console.BackgroundColor = defaultColor;
- bar = "";
- for (int i = value; i < maxValue; i++)
- {
- bar += '_';
- }
- Console.Write(bar + ']' + "\n\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement