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 HealthManaBar
- {
- class Program
- {
- static void Main(string[] args)
- {
- int precentHealth = 40;
- DrawBar(precentHealth, 1, ConsoleColor.Red);
- Console.ReadKey();
- }
- static void DrawBar(int precent, int position, ConsoleColor color, int maxValue = 10)
- {
- ConsoleColor defaultColor = Console.BackgroundColor;
- string bar = "";
- int value = maxValue * precent / 100;
- for (int i = 0; i < value; i++)
- {
- bar += "#";
- }
- 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