Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace CSLight_4._2
- {
- class Program
- {
- static void Main(string[] args)
- {
- int health, maxHealth = 10;
- int cursPosX, cursPosY;
- while (true)
- {
- Console.WriteLine("Введите координаты положения курсора: ");
- cursPosX = Convert.ToInt32(Console.ReadLine());
- cursPosY = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Введите значение здоровья ");
- health = Convert.ToInt32(Console.ReadLine());
- DrawBar(health, maxHealth, ConsoleColor.Red, cursPosX, cursPosY);
- Console.ReadKey();
- Console.Clear();
- }
- }
- static void DrawBar(int value, int maxValue, ConsoleColor color, int positionX, int positionY)
- {
- ConsoleColor defaultColor = Console.BackgroundColor;
- string bar = "";
- for (int i = 0; i < value; i++)
- {
- bar += "#";
- }
- Console.SetCursorPosition(positionX, positionY);
- Console.Write("[");
- Console.BackgroundColor = color;
- Console.Write(bar);
- bar = "";
- for (int i = value; i < maxValue; i++)
- {
- bar += " ";
- }
- Console.Write(bar);
- Console.BackgroundColor = defaultColor;
- Console.Write("]");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement