Advertisement
Guest User

4.2

a guest
Oct 22nd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 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 ConsoleApp1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             HealthBar(40);
  14.             Console.SetCursorPosition(45, 11);
  15.            
  16.             Console.Write("Введите количество хп в % максимальное значение 100%: ");
  17.             int playerhp = Convert.ToInt32(Console.ReadLine());
  18.            
  19.             HealthBar(playerhp);
  20.  
  21.             Console.ReadLine();
  22.         }
  23.         static void HealthBar(int persent)
  24.         {
  25.             int maxhp = 100;
  26.             Console.SetCursorPosition(45, 10);
  27.  
  28.  
  29.             if (persent <= maxhp)
  30.             {
  31.                 Console.Write("HP: [");
  32.                 persent /= 10;
  33.                 for (int i = 0; i < persent; i++)
  34.                 {
  35.                     Console.Write('#');
  36.                 }
  37.                 for (int i = persent; i < 10; i++)
  38.                 {
  39.                     Console.Write('_');
  40.                 }
  41.                 Console.Write(']');
  42.             }
  43.             else
  44.             {
  45.                 Console.Clear();
  46.                 Console.ForegroundColor = ConsoleColor.Red;
  47.                 Console.WriteLine("Вы ввели слишком большое количество здоровья");
  48.             }
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement