render: implement experimental font change, needs work
This commit is contained in:
parent
6281c756a8
commit
59db4e7d79
5 changed files with 21 additions and 14 deletions
BIN
assets/fonts/Royal_Decree.ttf
Normal file
BIN
assets/fonts/Royal_Decree.ttf
Normal file
Binary file not shown.
BIN
assets/fonts/Royal_Decree_Bold.ttf
Normal file
BIN
assets/fonts/Royal_Decree_Bold.ttf
Normal file
Binary file not shown.
|
|
@ -496,7 +496,11 @@ void load_audio_assets(GameState *gs) {
|
|||
static void game_loop(void) {
|
||||
GameState gs;
|
||||
memset(&gs, 0, sizeof(GameState));
|
||||
// load external assets
|
||||
// sound
|
||||
load_audio_assets(&gs);
|
||||
// font
|
||||
Font fontTTF = LoadFontEx("./assets/fonts/Royal_Decree_Bold.ttf", 14, 0, 250);
|
||||
// Initialize first floor
|
||||
rng_seed(12345);
|
||||
init_floor(&gs, 1);
|
||||
|
|
@ -549,7 +553,7 @@ static void game_loop(void) {
|
|||
|
||||
// Floating texts follow world shake
|
||||
render_floating_texts(gs.floating_texts, gs.floating_count, gs.shake_x, gs.shake_y);
|
||||
render_ui(&gs.player);
|
||||
render_ui(&gs.player, &fontTTF);
|
||||
|
||||
// Draw action log
|
||||
render_action_log(gs.action_log, gs.log_count, gs.log_head);
|
||||
|
|
|
|||
27
src/render.c
27
src/render.c
|
|
@ -108,7 +108,9 @@ void render_items(const Item *items, int count) {
|
|||
}
|
||||
}
|
||||
|
||||
void render_ui(const Player *p) {
|
||||
void render_ui(const Player *p, Font *font) {
|
||||
float nar_space = 1.0;
|
||||
float norm_space = 4.0;
|
||||
// HUD Panel
|
||||
const int hud_y = MAP_HEIGHT * TILE_SIZE;
|
||||
const int hud_height = 60;
|
||||
|
|
@ -152,7 +154,7 @@ void render_ui(const Player *p) {
|
|||
int bar_height = 16;
|
||||
|
||||
// HP Label, above bar
|
||||
DrawText("HP", bar_x, bar_y - 11, 9, text_dim);
|
||||
DrawTextEx(*font, "HP", (Vector2){bar_x, bar_y - 11}, 14, nar_space, text_dim);
|
||||
|
||||
// HP Bar background
|
||||
DrawRectangle(bar_x, bar_y, bar_width, bar_height, (Color){20, 15, 15, 255});
|
||||
|
|
@ -177,8 +179,8 @@ void render_ui(const Player *p) {
|
|||
// HP text, centered in bar
|
||||
char hp_text[32];
|
||||
snprintf(hp_text, sizeof(hp_text), "%d/%d", p->hp, p->max_hp);
|
||||
int hp_text_w = MeasureText(hp_text, 10);
|
||||
DrawText(hp_text, bar_x + (bar_width - hp_text_w) / 2, bar_y + 2, 10, WHITE);
|
||||
int hp_text_w = MeasureText(hp_text, 12);
|
||||
DrawTextEx(*font, hp_text, (Vector2){bar_x + (bar_width - hp_text_w) / 2.0f, bar_y + 2}, 12, nar_space, WHITE);
|
||||
|
||||
// Status effects
|
||||
int effect_x = bar_x;
|
||||
|
|
@ -213,7 +215,7 @@ void render_ui(const Player *p) {
|
|||
if (p->effects[i].duration > 0) {
|
||||
char eff_text[16];
|
||||
snprintf(eff_text, sizeof(eff_text), "%s%d", eff_label, p->effects[i].duration);
|
||||
DrawText(eff_text, effect_x, effect_y, 9, eff_color);
|
||||
DrawTextEx(*font, eff_text, (Vector2){effect_x, effect_y}, 9, nar_space, eff_color);
|
||||
effect_x += 28;
|
||||
}
|
||||
}
|
||||
|
|
@ -225,26 +227,27 @@ void render_ui(const Player *p) {
|
|||
// Floor
|
||||
char floor_text[16];
|
||||
snprintf(floor_text, sizeof(floor_text), "F%d", p->floor);
|
||||
DrawText(floor_text, stats_x, stats_y, 14, text_bright);
|
||||
DrawText("Floor", stats_x, stats_y + 16, 9, text_dim);
|
||||
DrawTextEx(*font, floor_text, (Vector2){stats_x, stats_y}, 16, norm_space, text_bright);
|
||||
DrawTextEx(*font, "Floor", (Vector2){stats_x, stats_y + 16}, 12, nar_space, text_dim);
|
||||
|
||||
// ATK
|
||||
char atk_text[16];
|
||||
snprintf(atk_text, sizeof(atk_text), "%d", p->attack);
|
||||
DrawText(atk_text, stats_x + stat_spacing, stats_y, 14, YELLOW);
|
||||
DrawText("ATK", stats_x + stat_spacing, stats_y + 16, 9, text_dim);
|
||||
DrawTextEx(*font, atk_text, (Vector2){stats_x + stat_spacing, stats_y}, 14, norm_space, YELLOW);
|
||||
DrawTextEx(*font, "ATK", (Vector2){stats_x + stat_spacing, stats_y + 16}, 9, nar_space, text_dim);
|
||||
|
||||
// DEF
|
||||
char def_text[16];
|
||||
snprintf(def_text, sizeof(def_text), "%d", p->defense);
|
||||
DrawText(def_text, stats_x + stat_spacing * 2, stats_y, 14, (Color){100, 150, 255, 255});
|
||||
DrawText("DEF", stats_x + stat_spacing * 2, stats_y + 16, 9, text_dim);
|
||||
DrawTextEx(*font, def_text, (Vector2){stats_x + stat_spacing * 2, stats_y}, 14, norm_space,
|
||||
(Color){100, 150, 255, 255});
|
||||
DrawTextEx(*font, "DEF", (Vector2){stats_x + stat_spacing * 2, stats_y + 16}, 9, nar_space, text_dim);
|
||||
|
||||
int equip_x = section2_end + 15;
|
||||
int equip_y = hud_y + 8;
|
||||
|
||||
// Weapon slot
|
||||
DrawText("WEAPON", equip_x, equip_y, 9, text_dim);
|
||||
DrawTextEx(*font, "WEAPON", (Vector2){equip_x, equip_y}, 9, nar_space, text_dim);
|
||||
if (p->has_weapon) {
|
||||
const char *weapon_name = item_get_name(&p->equipped_weapon);
|
||||
if (weapon_name) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ void render_enemies(const Enemy *enemies, int count);
|
|||
void render_items(const Item *items, int count);
|
||||
|
||||
// Render UI overlay
|
||||
void render_ui(const Player *p);
|
||||
void render_ui(const Player *p, Font *font);
|
||||
|
||||
// Render action log (bottom left corner)
|
||||
void render_action_log(const char log[5][128], int count, int head);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue