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 _29
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- float maxValueHealthBar = 10;
- DrawHealthBar(maxValueHealthBar);
- }
- static void DrawHealthBar(float maxValue)
- {
- float fullBarInPercent = 100;
- float emptyBarInPercent = 0;
- Console.WriteLine("Вы в меню отрисовки Health bar!!!");
- Console.WriteLine("Введите позицию отрисовки по оси X");
- int positionHealthBarX = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Введите позицию отрисовки по оси Y");
- int positionHealthBarY = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Введите на сколько процентов отрисовать healthbar: ");
- float userInput = Convert.ToSingle(Console.ReadLine());
- float userInputInPercent = (float)Math.Round((maxValue / fullBarInPercent) * userInput);
- string bar = "";
- char fillSymbol = '#';
- char emptySymbol = '_';
- char openBracket = '[';
- char closeBracket = ']';
- if (userInput >= emptyBarInPercent && userInput <= fullBarInPercent)
- {
- for (float i = 0; i < userInputInPercent; i++)
- {
- bar += fillSymbol;
- }
- Console.SetCursorPosition(positionHealthBarX, positionHealthBarY);
- Console.Write(openBracket);
- Console.Write(bar);
- bar = "";
- for (float i = userInputInPercent; i < maxValue; i++)
- {
- bar += emptySymbol;
- }
- Console.WriteLine(bar + closeBracket);
- }
- else
- {
- Console.WriteLine("Введено значение выходящее за пределы Healthbar!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement