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 Study
- {
- class Program
- {
- static void Main(string[] args)
- {
- int health = 4; int maxHealth = 10;
- int mana = 3, maxMana = 10;
- DrawBar(health, maxHealth, ConsoleColor.Red, 0, '#');
- DrawBar(mana, maxMana, ConsoleColor.Blue, 1);
- }
- static void DrawBar(int value, int maxValue, ConsoleColor color,int position, char symbol= ' ') {
- ConsoleColor defaultColor = Console.BackgroundColor;
- string bar = "";
- for (int i = 0; i < value; i++) {
- bar += symbol;
- }
- Console.SetCursorPosition(0, position);
- 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