Created
May 30, 2025 17:07
-
-
Save niklib-go/ba5e5ba3ecd8f0d1150707e0ec5052aa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace CLa | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
int healthbarPosX = 30; | |
int healthbarPosY = 1; | |
int healthbarLength = 10; | |
int healthbarPercentValue = 40; | |
RenderHealthdar(healthbarPercentValue, healthbarLength, healthbarPosX, healthbarPosY); | |
} | |
static void RenderHealthdar(int healthbarPercentValue, int healthbarLength, int healthbarPosX, int healthbarPosY) | |
{ | |
ConsoleColor defalutBackgroundColor = Console.BackgroundColor; | |
ConsoleColor defaultForegroundColor = Console.ForegroundColor; | |
int filledLngth = healthbarPercentValue * healthbarLength / 100; | |
Console.SetCursorPosition(healthbarPosX, healthbarPosY); | |
Console.Write("["); | |
Console.BackgroundColor = ConsoleColor.Red; | |
Console.ForegroundColor = ConsoleColor.White; | |
for (int i = 0; i < filledLngth; i++) | |
{ | |
Console.Write("#"); | |
} | |
Console.BackgroundColor = ConsoleColor.DarkGray; | |
for (int i = 0; i < healthbarLength - filledLngth; i++) | |
{ | |
Console.Write("_"); | |
} | |
Console.BackgroundColor = defalutBackgroundColor; | |
Console.ForegroundColor = defaultForegroundColor; | |
Console.Write("]"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment