Advertisement
Vadim_Rogulev

Untitled

Apr 19th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.51 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace UIElement
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Bar(50, 100, ConsoleColor.Red, 5, '#');
  14.             Bar(40, 100, ConsoleColor.Blue, 7, '#');
  15.         }
  16.         static void Bar(int now, int max, ConsoleColor color, int pos, char barChar = ' ')
  17.         {
  18.             Console.SetCursorPosition(0, 4);
  19.             Console.Write("HEALTH");
  20.             Console.SetCursorPosition(0, 6);
  21.             Console.Write("MANA");
  22.             ConsoleColor defaultColor = Console.BackgroundColor;
  23.             string bar = "#";
  24.             for(int i = 0; i < now; i++)
  25.             {
  26.                 bar += barChar;  
  27.             }
  28.             Console.SetCursorPosition(0, pos);
  29.             Console.Write("|");
  30.             Console.BackgroundColor = color;
  31.             Console.Write(bar);
  32.             bar = "_";
  33.             for(int i = now; i < max; i++)
  34.             {
  35.                bar += barChar;
  36.             }
  37.             Console.SetCursorPosition(now+1, pos);
  38.             Console.BackgroundColor = defaultColor;
  39.             for (int i = now; i <= max; i++)
  40.             {
  41.                 if( i == max)
  42.                 {
  43.                     Console.Write("|");
  44.                 }
  45.                 else
  46.                 {
  47.                     Console.Write("_");
  48.                 }
  49.             }
  50.            
  51.            
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement