font: extensive tweaks, looks much better
This commit is contained in:
parent
64205e137c
commit
a53942249c
4 changed files with 37 additions and 21 deletions
BIN
assets/fonts/Tomorrow_Night.ttf
Normal file
BIN
assets/fonts/Tomorrow_Night.ttf
Normal file
Binary file not shown.
|
|
@ -508,7 +508,7 @@ static void game_loop(void) {
|
|||
// sound
|
||||
load_audio_assets(&gs);
|
||||
// font
|
||||
Font fontTTF = LoadFontEx("./assets/fonts/Royal_Decree_Bold.ttf", 14, 0, 250);
|
||||
Font fontTTF = LoadFontEx("./assets/fonts/Tomorrow_Night.ttf", 24, NULL, 0);
|
||||
// Initialize first floor
|
||||
rng_seed(12345);
|
||||
init_floor(&gs, 1);
|
||||
|
|
|
|||
45
src/render.c
45
src/render.c
|
|
@ -153,7 +153,7 @@ void render_ui(const Player *p, Font *font) {
|
|||
int bar_height = 16;
|
||||
|
||||
// HP Label, above bar
|
||||
DrawTextEx(*font, "HP", (Vector2){bar_x, bar_y - 11}, 14, NAR_CHAR_SPACE, text_dim);
|
||||
DrawTextEx(*font, "HP", (Vector2){bar_x, bar_y - 17}, BIG_FONT, NAR_CHAR_SPACE, text_dim);
|
||||
|
||||
// HP Bar background
|
||||
DrawRectangle(bar_x, bar_y, bar_width, bar_height, (Color){20, 15, 15, 255});
|
||||
|
|
@ -179,7 +179,8 @@ void render_ui(const Player *p, Font *font) {
|
|||
char hp_text[32];
|
||||
snprintf(hp_text, sizeof(hp_text), "%d/%d", p->hp, p->max_hp);
|
||||
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_CHAR_SPACE, WHITE);
|
||||
DrawTextEx(*font, hp_text, (Vector2){bar_x + (bar_width - hp_text_w) / 2.0f, bar_y + 2}, MEDIUM_FONT,
|
||||
SMALL_CHAR_SPACE, WHITE);
|
||||
|
||||
// Status effects
|
||||
int effect_x = bar_x;
|
||||
|
|
@ -214,7 +215,7 @@ void render_ui(const Player *p, Font *font) {
|
|||
if (p->effects[i].duration > 0) {
|
||||
char eff_text[16];
|
||||
snprintf(eff_text, sizeof(eff_text), "%s%d", eff_label, p->effects[i].duration);
|
||||
DrawTextEx(*font, eff_text, (Vector2){effect_x, effect_y}, 9, NAR_CHAR_SPACE, eff_color);
|
||||
DrawTextEx(*font, eff_text, (Vector2){effect_x, effect_y}, SMALL_FONT, NAR_CHAR_SPACE, eff_color);
|
||||
effect_x += 28;
|
||||
}
|
||||
}
|
||||
|
|
@ -246,7 +247,7 @@ void render_ui(const Player *p, Font *font) {
|
|||
int equip_y = hud_y + 8;
|
||||
|
||||
// Weapon slot
|
||||
DrawTextEx(*font, "WEAPON", (Vector2){equip_x, equip_y}, 12, NAR_CHAR_SPACE, text_dim);
|
||||
DrawTextEx(*font, "WEAPON", (Vector2){equip_x, equip_y}, MEDIUM_FONT, NAR_CHAR_SPACE, text_dim);
|
||||
if (p->has_weapon) {
|
||||
const char *weapon_name = item_get_name(&p->equipped_weapon);
|
||||
if (weapon_name) {
|
||||
|
|
@ -260,7 +261,7 @@ void render_ui(const Player *p, Font *font) {
|
|||
}
|
||||
|
||||
// Armor slot
|
||||
DrawTextEx(*font, "ARMOR", (Vector2){equip_x, equip_y + 26}, 9, NAR_CHAR_SPACE, text_dim);
|
||||
DrawTextEx(*font, "ARMOR", (Vector2){equip_x, equip_y + 26}, MEDIUM_FONT, NAR_CHAR_SPACE, text_dim);
|
||||
if (p->has_armor) {
|
||||
const char *armor_name = item_get_name(&p->equipped_armor);
|
||||
if (armor_name) {
|
||||
|
|
@ -275,9 +276,9 @@ void render_ui(const Player *p, Font *font) {
|
|||
int ctrl_x = section3_end + 20;
|
||||
int ctrl_y = hud_y + 14;
|
||||
|
||||
DrawTextEx(*font, "[WASD] Move [G] Pickup [I] Inventory [U] Use", (Vector2){ctrl_x, ctrl_y}, 11,
|
||||
NORM_CHAR_SPACE, (Color){139, 119, 89, 255});
|
||||
DrawTextEx(*font, "[E] Equip [D] Drop [Q] Quit", (Vector2){ctrl_x, ctrl_y + 16}, 11, NORM_CHAR_SPACE,
|
||||
DrawTextEx(*font, "[WASD] Move [G] Pickup [I] Inventory [U] Use", (Vector2){ctrl_x, ctrl_y}, MEDIUM_FONT,
|
||||
MED_CHAR_SPACE, (Color){139, 119, 89, 255});
|
||||
DrawTextEx(*font, "[E] Equip [D] Drop [Q] Quit", (Vector2){ctrl_x, ctrl_y + 16}, MEDIUM_FONT, MED_CHAR_SPACE,
|
||||
(Color){139, 119, 89, 255});
|
||||
|
||||
// INV count in top-right corner of HUD
|
||||
|
|
@ -309,7 +310,8 @@ void render_action_log(const char log[5][128], int count, int head, Font *font)
|
|||
|
||||
// Title bar
|
||||
DrawRectangle(log_x + 4, log_y + 4, log_width - 8, 16, (Color){30, 25, 20, 255});
|
||||
DrawTextEx(*font, "MESSAGE LOG", (Vector2){log_x + 8, log_y + 6}, 10, NAR_CHAR_SPACE, (Color){180, 160, 130, 255});
|
||||
DrawTextEx(*font, "MESSAGE LOG", (Vector2){log_x + 8, log_y + 6}, MEDIUM_FONT, NAR_CHAR_SPACE,
|
||||
(Color){180, 160, 130, 255});
|
||||
|
||||
// Separator line under title
|
||||
DrawLine(log_x + 4, log_y + 22, log_x + log_width - 5, log_y + 22, log_border_dark);
|
||||
|
|
@ -342,7 +344,7 @@ void render_action_log(const char log[5][128], int count, int head, Font *font)
|
|||
void render_inventory_overlay(const Player *p, int selected, Font *font) {
|
||||
// Overlay dimensions
|
||||
int ov_width = 360;
|
||||
int ov_height = 300;
|
||||
int ov_height = 320;
|
||||
Rectangle overlay = {(float)(SCREEN_WIDTH - ov_width) / 2, (float)(SCREEN_HEIGHT - ov_height) / 2 - 60,
|
||||
(float)ov_width, (float)ov_height};
|
||||
DrawRectangleRec(overlay, (Color){12, 12, 12, 252});
|
||||
|
|
@ -351,13 +353,14 @@ void render_inventory_overlay(const Player *p, int selected, Font *font) {
|
|||
// Title
|
||||
const char *title = "INVENTORY";
|
||||
int title_w = MeasureText(title, 24);
|
||||
DrawTextEx(*font, title, (Vector2){overlay.x + (overlay.width - title_w) / 2, overlay.y + 12}, 24, NORM_CHAR_SPACE,
|
||||
WHITE);
|
||||
Vector2 t_w = MeasureTextEx(*font, title, 30, NORM_CHAR_SPACE);
|
||||
DrawTextEx(*font, title, (Vector2){overlay.x + (overlay.width - t_w.x) / 2, overlay.y + 10}, HUGE_FONT,
|
||||
NORM_CHAR_SPACE, WHITE);
|
||||
|
||||
// Draw each inventory slot
|
||||
char slot_text[64];
|
||||
int row_height = 26;
|
||||
int start_y = overlay.y + 50;
|
||||
int start_y = overlay.y + 40;
|
||||
|
||||
for (int i = 0; i < MAX_INVENTORY; i++) {
|
||||
int y_pos = start_y + (i * row_height);
|
||||
|
|
@ -374,14 +377,15 @@ void render_inventory_overlay(const Player *p, int selected, Font *font) {
|
|||
|
||||
// Slot number
|
||||
snprintf(slot_text, sizeof(slot_text), "%d.", i + 1);
|
||||
DrawTextEx(*font, slot_text, (Vector2){overlay.x + 16, y_pos + 4}, 14, NORM_CHAR_SPACE, (Color){80, 80, 80, 255});
|
||||
DrawTextEx(*font, slot_text, (Vector2){overlay.x + 16, y_pos + 4}, MEDIUM_FONT, SMALL_CHAR_SPACE,
|
||||
(Color){80, 80, 80, 255});
|
||||
|
||||
// Item name
|
||||
const char *name = item_get_name(item);
|
||||
if (name) {
|
||||
Color name_color = (item->type == ITEM_POTION) ? (Color){255, 140, 140, 255}
|
||||
: (item->type == ITEM_WEAPON) ? (Color){255, 255, 140, 255}
|
||||
: (Color){140, 140, 255, 255};
|
||||
: (item->type == ITEM_WEAPON) ? (Color){255, 255, 140, 255}
|
||||
: (Color){140, 140, 255, 255};
|
||||
DrawTextEx(*font, name, (Vector2){overlay.x + 45, y_pos + 4}, 14, NORM_CHAR_SPACE, name_color);
|
||||
}
|
||||
// Power
|
||||
|
|
@ -397,15 +401,16 @@ void render_inventory_overlay(const Player *p, int selected, Font *font) {
|
|||
} else {
|
||||
// Empty slot
|
||||
snprintf(slot_text, sizeof(slot_text), "%d.", i + 1);
|
||||
DrawTextEx(*font, slot_text, (Vector2){overlay.x + 16, y_pos + 4}, 14, NORM_CHAR_SPACE, (Color){40, 40, 40, 255});
|
||||
DrawTextEx(*font, slot_text, (Vector2){overlay.x + 16, y_pos + 4}, MEDIUM_FONT, SMALL_CHAR_SPACE,
|
||||
(Color){40, 40, 40, 255});
|
||||
}
|
||||
}
|
||||
|
||||
// Instructions at bottom
|
||||
const char *hint = "[1-0] Select [E] Equip [U] Use [D] Drop [I/ESC] Close";
|
||||
int hint_w = MeasureText(hint, 12);
|
||||
DrawTextEx(*font, hint, (Vector2){overlay.x + (overlay.width - hint_w) / 2, overlay.y + overlay.height - 22}, 12,
|
||||
NORM_CHAR_SPACE, (Color){65, 65, 65, 255});
|
||||
Vector2 hint_w = MeasureTextEx(*font, hint, NORM_FONT, NAR_CHAR_SPACE);
|
||||
DrawTextEx(*font, hint, (Vector2){overlay.x + (overlay.width - hint_w.x) / 2, overlay.y + overlay.height - 22},
|
||||
NORM_FONT, NAR_CHAR_SPACE, (Color){80, 80, 80, 255});
|
||||
}
|
||||
|
||||
static Color label_color(FloatingText *ft, int alpha) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,18 @@
|
|||
|
||||
// Font constants
|
||||
#define NORM_CHAR_SPACE 4.0f
|
||||
#define MED_CHAR_SPACE 2.5f
|
||||
#define SMALL_CHAR_SPACE 1.6f
|
||||
#define NAR_CHAR_SPACE 1.0f
|
||||
#define CRAMPED_CHAR_SPACE 0.5f
|
||||
|
||||
#define TINY_FONT 8
|
||||
#define SMALL_FONT 10
|
||||
#define NORM_FONT 12
|
||||
#define MEDIUM_FONT 14
|
||||
#define LARGE_FONT 18
|
||||
#define BIG_FONT 22
|
||||
#define HUGE_FONT 30
|
||||
|
||||
// Game Limits
|
||||
#define MAX_ENEMIES 64
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue