kwest87

Untitled

Jan 22nd, 2024
695
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.54 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.             int health = 50;
  10.             int mana = 30;
  11.             int maximumHealth = 100;
  12.             int maximumMana = 100;
  13.             int healthPosition = 0;
  14.             int manaPosition = 1;
  15.             char healthSymbol = 'h';
  16.             char manaSymbol = 'm';
  17.             bool isWork = true;
  18.  
  19.             while (isWork)
  20.             {
  21.                 RenderingBar(health, maximumHealth, healthPosition, healthSymbol, ConsoleColor.Red);
  22.                 RenderingBar(mana, maximumMana, manaPosition, manaSymbol, ConsoleColor.DarkCyan);
  23.             }
  24.         }
  25.  
  26.         static void RenderingIndicator(int value, int maximumValue, char sumbol, ConsoleColor color)
  27.         {
  28.             Console.BackgroundColor = color;
  29.             string indicator = "";
  30.  
  31.             for (int i = value; i < maximumValue; i++)
  32.             {
  33.                 indicator += sumbol;
  34.             }
  35.  
  36.             Console.Write(indicator);
  37.         }
  38.  
  39.         static void RenderingBar(int value, int maximumValue, int position, char sumbol, ConsoleColor color)
  40.         {
  41.             Console.SetCursorPosition(0, position);
  42.             ConsoleColor original = Console.BackgroundColor;
  43.             Console.Write("[");
  44.             RenderingIndicator(0, value, sumbol, color);
  45.             RenderingIndicator(value, maximumValue, sumbol, original);
  46.             Console.WriteLine("]");
  47.             Console.ReadKey();
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment