Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp29
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Random random = new Random();
- int maximumValue = 1000;
- int health = random.Next(maximumValue);
- int mana = random.Next(maximumValue);
- int maximumHealth = random.Next(health, maximumValue + 1);
- int maximumMana = random.Next(mana, maximumValue + 1);
- int maximumBarUnit = 10;
- int valueHealthScale = maximumHealth / maximumBarUnit;
- int valueManaScale = maximumMana / maximumBarUnit;
- int quantityHealthScale = health / valueHealthScale;
- int quantityManaScale = mana / valueManaScale;
- int healthPosition = 0;
- int manaPosition = 1;
- char healthSymbol = 'h';
- char manaSymbol = 'm';
- bool isWork = true;
- while (isWork)
- {
- RenderingBar(quantityHealthScale, maximumBarUnit, healthPosition, healthSymbol, ConsoleColor.Red);
- RenderingBar(quantityManaScale, maximumBarUnit, manaPosition, manaSymbol, ConsoleColor.DarkCyan);
- Console.ReadKey();
- }
- }
- static void RenderingPartsBar(int value, int maximumValue, char sumbol, ConsoleColor color)
- {
- Console.BackgroundColor = color;
- string partBar = "";
- for (int i = value; i < maximumValue; i++)
- {
- partBar += sumbol;
- }
- Console.Write(partBar);
- }
- static void RenderingBar(int value, int maximumValue, int position, char sumbol, ConsoleColor color)
- {
- Console.SetCursorPosition(0, position);
- ConsoleColor original = Console.BackgroundColor;
- Console.Write("[");
- RenderingPartsBar(0, value, sumbol, color);
- RenderingPartsBar(value, maximumValue, sumbol, original);
- Console.WriteLine("]");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment