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 _4t464
- {
- class Program
- {
- static void Main(string[] args)
- {
- Random rand = new Random();
- int barSize = 10;
- string hp = "Health -";
- string mg = "Mana -";
- int percent = rand.Next(0, 11);
- DrowBar(hp,percent,barSize,ConsoleColor.Red, 0, '_');
- percent = rand.Next(0, 11);
- DrowBar(mg,percent,barSize,ConsoleColor.DarkGreen, 1, '_');
- Console.ReadKey();
- }
- static void DrowBar(string name,int percent, int barSize,ConsoleColor color, int position,char symbol = ' ')
- {
- ConsoleColor defaultColor = Console.BackgroundColor;
- string bar = "";
- for (int 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 (int j = percent; j < barSize; j++)
- {
- bar += symbol;
- }
- Console.Write($"{bar}]");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement