kwest87

Untitled

Jan 22nd, 2024
873
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.04 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp29
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Random random = new Random();
  10.             int maximumValue = 1000;
  11.             int health = random.Next(maximumValue);
  12.             int mana = random.Next(maximumValue);
  13.             int maximumHealth = random.Next(health, maximumValue + 1);
  14.             int maximumMana = random.Next(mana, maximumValue + 1);
  15.             int maximumBarUnit = 10;
  16.             int valueHealthScale = maximumHealth / maximumBarUnit;
  17.             int valueManaScale = maximumMana / maximumBarUnit;
  18.             int quantityHealthScale = health / valueHealthScale;
  19.             int quantityManaScale = mana / valueManaScale;
  20.             int healthPosition = 0;
  21.             int manaPosition = 1;
  22.             char healthSymbol = 'h';
  23.             char manaSymbol = 'm';
  24.             bool isWork = true;
  25.  
  26.             while (isWork)
  27.             {
  28.                 RenderingBar(quantityHealthScale, maximumBarUnit, healthPosition, healthSymbol, ConsoleColor.Red);
  29.                 RenderingBar(quantityManaScale, maximumBarUnit, manaPosition, manaSymbol, ConsoleColor.DarkCyan);
  30.                 Console.ReadKey();
  31.             }
  32.         }
  33.  
  34.         static void RenderingPartsBar(int value, int maximumValue, char sumbol, ConsoleColor color)
  35.         {
  36.             Console.BackgroundColor = color;
  37.             string partBar = "";
  38.  
  39.             for (int i = value; i < maximumValue; i++)
  40.             {
  41.                 partBar += sumbol;
  42.             }
  43.  
  44.             Console.Write(partBar);
  45.         }
  46.  
  47.         static void RenderingBar(int value, int maximumValue, int position, char sumbol, ConsoleColor color)
  48.         {
  49.             Console.SetCursorPosition(0, position);
  50.             ConsoleColor original = Console.BackgroundColor;
  51.             Console.Write("[");
  52.             RenderingPartsBar(0, value, sumbol, color);
  53.             RenderingPartsBar(value, maximumValue, sumbol, original);
  54.             Console.WriteLine("]");
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment