Advertisement
SLENSER

Untitled

May 22nd, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. namespace _4_2
  2. {
  3.     class Program
  4.     {
  5.         static void Main(string[] args)
  6.         {
  7.             int health = 2;
  8.  
  9.             HealthBar(health);
  10.         }
  11.         static void HealthBar (int health, int posX = 0, int posY = 0, char barChar = '#')
  12.         {
  13.             char[] healthBar = { '[', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', ']' };
  14.  
  15.             for (int i = 0; i < health / 10 && i != 10; i++)
  16.                 healthBar[i + 1] = barChar;
  17.            
  18.            
  19.             Console.SetCursorPosition(posX, posY);
  20.  
  21.            
  22.  
  23.             for (int i = 0; i < healthBar.Length; i++)
  24.                 Console.Write(healthBar[i]);
  25.  
  26.         }
  27.        
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement