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 UIElement
- {
- class Program
- {
- static void Main(string[] args)
- {
- Bar(50, 100, ConsoleColor.Red, 5, '#');
- Bar(40, 100, ConsoleColor.Blue, 7, '#');
- }
- static void Bar(int now, int max, ConsoleColor color, int pos, char barChar = ' ')
- {
- Console.SetCursorPosition(0, 4);
- Console.Write("HEALTH");
- Console.SetCursorPosition(0, 6);
- Console.Write("MANA");
- ConsoleColor defaultColor = Console.BackgroundColor;
- string bar = "#";
- for(int i = 0; i < now; i++)
- {
- bar += barChar;
- }
- Console.SetCursorPosition(0, pos);
- Console.Write("|");
- Console.BackgroundColor = color;
- Console.Write(bar);
- bar = "_";
- for(int i = now; i < max; i++)
- {
- bar += barChar;
- }
- Console.SetCursorPosition(now+1, pos);
- Console.BackgroundColor = defaultColor;
- for (int i = now; i <= max; i++)
- {
- if( i == max)
- {
- Console.Write("|");
- }
- else
- {
- Console.Write("_");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement