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 Lessen4
- {
- class Program
- {
- static void Main(string[] args)
- {
- int health;
- int maxHealth = 10;
- while(true)
- {
- Console.Write("Введите количество жизней (0...100): ");
- health = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine();
- Drawbar(health, maxHealth, 1, 1, ConsoleColor.Magenta);
- Console.ReadKey();
- Console.Clear();
- }
- }
- static void Drawbar(int health, int maxValue, int posX, int posY, ConsoleColor color, char barChar =' ' )
- {
- if (health % 10 == 0)
- health = health / 10;
- else
- health = health / 10+1;
- ConsoleColor defaultColor = Console.BackgroundColor;
- Console.BackgroundColor = color;
- string bar = "";
- for(int i =0; i< health; i++)
- {
- bar += barChar;
- }
- Console.SetCursorPosition(posX, posY);
- Console.BackgroundColor = defaultColor;
- Console.Write("[");
- Console.BackgroundColor = color;
- Console.Write(bar);
- bar = "";
- for(int i = health; i<maxValue;i++)
- {
- bar += barChar;
- }
- Console.BackgroundColor = defaultColor;
- Console.Write(bar+"]");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement