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)
- {
- int health = 50;
- int mana = 30;
- int maximumHealth = 100;
- int maximumMana = 100;
- int healthPosition = 0;
- int manaPosition = 1;
- char healthSymbol = 'h';
- char manaSymbol = 'm';
- bool isWork = true;
- while (isWork)
- {
- RenderingBar(health, maximumHealth, healthPosition, healthSymbol, ConsoleColor.Red);
- RenderingBar(mana, maximumMana, manaPosition, manaSymbol, ConsoleColor.DarkCyan);
- }
- }
- static void RenderingIndicator(int value, int maximumValue, char sumbol, ConsoleColor color)
- {
- Console.BackgroundColor = color;
- string indicator = "";
- for (int i = value; i < maximumValue; i++)
- {
- indicator += sumbol;
- }
- Console.Write(indicator);
- }
- static void RenderingBar(int value, int maximumValue, int position, char sumbol, ConsoleColor color)
- {
- Console.SetCursorPosition(0, position);
- ConsoleColor original = Console.BackgroundColor;
- Console.Write("[");
- RenderingIndicator(0, value, sumbol, color);
- RenderingIndicator(value, maximumValue, sumbol, original);
- Console.WriteLine("]");
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment