Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace CSLight2
- {
- class Program
- {
- static void Main(string[] args)
- {
- int posX = 0, posY = 0;
- float health = 10;
- Console.WriteLine("Введи координаты расположения бара!\n");
- Console.Write("Сместить по горизонтали на (0 - 10): ");
- posX = Convert.ToInt32(Console.ReadLine());
- Console.Write("Сместить по вертикали на (0 - 10): ");
- posY = Convert.ToInt32(Console.ReadLine());
- Console.Clear();
- HealthBar(posX, posY, health);
- }
- static void HealthBar(int posX, int posY, float health)
- {
- int maxHealth = 10;
- bool barOn = true;
- while(barOn == true)
- {
- ConsoleColor defaultColor = Console.BackgroundColor;
- string healthStats = "";
- for (int i = 0; i < health; i++)
- {
- healthStats += ' ';
- }
- Console.SetCursorPosition(posX, posY);
- Console.Write("[");
- Console.BackgroundColor = ConsoleColor.Green;
- Console.Write(healthStats);
- healthStats = "";
- for (float i = health; i < maxHealth; i++)
- {
- healthStats += ' ';
- }
- Console.BackgroundColor = defaultColor;
- Console.WriteLine(healthStats + "]" + (health * 10) + "%");
- Console.Write("Сколько сейчас процентов здоровья (0; 0,1...9,9; 10)? ");
- health = Convert.ToSingle(Console.ReadLine());
- Console.Clear();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment