Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Collections.Specialized;
- using System.Diagnostics.CodeAnalysis;
- using System.Dynamic;
- using System.Globalization;
- using System.Linq;
- using System.Runtime.Serialization;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- namespace CSLight
- {
- class Program
- {
- static void Main(string[] args)
- {
- int healthPercent = 10;
- int manaPercent = 70;
- DrawBAr(healthPercent, ConsoleColor.Red, 0);
- DrawBAr(manaPercent, ConsoleColor.Blue, 1);
- }
- static void DrawBAr(int filledPercentage, ConsoleColor color, int position)
- {
- int maxPercent = 100;
- int oneScaleDivision = 10;
- int scale = filledPercentage / oneScaleDivision;
- ConsoleColor defaultColor = Console.BackgroundColor;
- string bar = "";
- for (int i = 0; i < scale; i++)
- {
- bar += '#';
- }
- Console.SetCursorPosition(0, position);
- Console.Write('[');
- Console.BackgroundColor = color;
- Console.Write(bar);
- Console.BackgroundColor = defaultColor;
- bar = "";
- for (int i = 0; i < (maxPercent / oneScaleDivision - scale); i++)
- {
- bar += '_';
- }
- Console.Write(bar + ']');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment