Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace CSharpLight_HomeWork20___Bar
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.CursorVisible = false;
- int healt = 5;
- int maxHealth = 10;
- int mana = 2;
- int maxMana = 15;
- DrawBar(maxHealth, healt, ConsoleColor.Red, 1, 1);
- DrawBar(maxMana, mana, ConsoleColor.Blue, 5 + maxHealth, 1);
- Console.ReadKey();
- }
- static void DrawBar(int maxValue, int value, 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);
- Console.BackgroundColor = defaultColor;
- bar = "";
- for (int i = value; i < maxValue; i++)
- {
- bar += ' ';
- }
- Console.Write(bar + "]");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement