Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.26 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. namespace ConsoleApp28
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int helth = 17;
  13.             int maxHealth = 20;
  14.             Healthbar(helth, maxHealth, ConsoleColor.DarkBlue);
  15.             Console.SetCursorPosition(0, 1);
  16.             Console.WriteLine($"У вас сейчас: {100 * helth / maxHealth}% ХП");
  17.             void Healthbar(int valueHp, int maxHp, ConsoleColor color)
  18.             {
  19.                 ConsoleColor defaultColor = Console.BackgroundColor;
  20.                 string HP = "";
  21.                 for (int i = 0; i < valueHp; i++)
  22.                 {
  23.                     HP += '#';
  24.                 }
  25.                 Console.SetCursorPosition(0, 0);
  26.                 Console.Write('[');
  27.                 Console.BackgroundColor = color;
  28.                 Console.Write(HP);
  29.                 Console.BackgroundColor = defaultColor;
  30.                 HP = "";
  31.                 for (int i = valueHp; i < maxHp; i++)
  32.                 {
  33.                     HP += '_';
  34.                 }
  35.                 Console.Write(HP + ']');
  36.             }
  37.             Console.ReadKey();
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement