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 FifthProject
- {
- class Program
- {
- static void Main(string[] args)
- {
- double health = 7;
- double maxHealth = 11;
- double healthProcent = ((health / (maxHealth / 100)) / 10)/1 - ((health / (maxHealth / 100)) / 10) % 1;
- DrawBar(Convert.ToInt32(healthProcent), 10, ConsoleColor.Red, 0, '#');
- Console.ReadKey();
- }
- static void DrawBar(int value , int maxValue, ConsoleColor fillColor, int positionY, char fillChar = ' ')
- {
- ConsoleColor defaultColor = Console.BackgroundColor;
- ConsoleColor frontColor = Console.ForegroundColor;
- Console.SetCursorPosition(0, 0);
- Console.Write('[');
- Console.ForegroundColor = fillColor;
- Console.Write(FillBar(0, value, fillChar));
- Console.ForegroundColor = defaultColor;
- Console.Write(FillBar(value, maxValue, fillChar));
- Console.ForegroundColor = frontColor;
- Console.Write(']');
- }
- static string FillBar(int start, int end, char fillChar)
- {
- string bar = "";
- for(int i = start; i < end; i++)
- {
- bar += fillChar;
- }
- return bar;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement