Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- public class Program
- {
- public static void Main()
- {
- DrawHealthBar(0.60f, 0.1f, 4, 1);
- DrawHealthBar(0.75f, 0.1f, 1, 4);
- }
- public static void DrawHealthBar(float percent, float percentPerCell, int positionX, int positionY, char sign = '#')
- {
- int cellsAmount = (int) (1.0f / percentPerCell);
- Console.SetCursorPosition(positionX, positionY);
- Console.Write("[");
- for (int i = 0; i < cellsAmount; ++i, percent -= percentPerCell)
- {
- if (percent > percentPerCell)
- Console.Write(sign);
- else
- Console.Write("_");
- }
- Console.Write("]\n");
- }
- }
Add Comment
Please, Sign In to add comment