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 CSharpLight
- {
- class Program
- {
- static void Main(string[] args)
- {
- float number = 10;
- string hb = "Healthbar - ";
- string mb = "ManaBar - ";
- DrawBar(hb, number, ConsoleColor.Red, 0, '_');
- DrawBar(mb, number, ConsoleColor.DarkGreen, 1, '_');
- Console.ReadKey();
- }
- static void DrawBar(string name, float value, ConsoleColor color, int position, char symbol = ' ')
- {
- Random rand = new Random();
- string bar = "";
- float percent = (rand.Next(0, 11) / value) * 10;
- ConsoleColor defaultColor = Console.BackgroundColor;
- for (float i = 0; i < percent; i++)
- {
- bar += symbol;
- }
- Console.SetCursorPosition(0, position);
- Console.Write(name);
- Console.Write('[');
- Console.BackgroundColor = color;
- Console.Write(bar);
- Console.BackgroundColor = defaultColor;
- bar = "";
- for (float j = percent; j < value; j++)
- {
- bar += symbol;
- }
- Console.Write($"{bar}]");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement