ranee

бак здоровья

Jul 23rd, 2020 (edited)
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.45 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.Specialized;
  4. using System.Diagnostics.CodeAnalysis;
  5. using System.Dynamic;
  6. using System.Globalization;
  7. using System.Linq;
  8. using System.Runtime.Serialization;
  9. using System.Text;
  10. using System.Threading;
  11. using System.Threading.Tasks;
  12. namespace CSLight
  13. {
  14.     class Program
  15.     {
  16.         static void Main(string[] args)
  17.         {
  18.             int healthPercent = 10;
  19.             int manaPercent = 70;
  20.             DrawBAr(healthPercent, ConsoleColor.Red, 0);
  21.             DrawBAr(manaPercent, ConsoleColor.Blue, 1);
  22.         }
  23.         static void DrawBAr(int filledPercentage,  ConsoleColor color, int position)
  24.         {
  25.             int maxPercent = 100;
  26.             int oneScaleDivision = 10;
  27.             int scale = filledPercentage / oneScaleDivision;
  28.             ConsoleColor defaultColor = Console.BackgroundColor;
  29.             string bar = "";
  30.             for (int i = 0; i < scale; i++)
  31.             {
  32.                 bar += '#';
  33.             }
  34.             Console.SetCursorPosition(0, position);
  35.             Console.Write('[');
  36.             Console.BackgroundColor = color;
  37.             Console.Write(bar);
  38.             Console.BackgroundColor = defaultColor;
  39.             bar = "";
  40.             for (int i = 0; i < (maxPercent / oneScaleDivision - scale); i++)
  41.             {
  42.                 bar += '_';
  43.             }
  44.             Console.Write(bar + ']');
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment