Compare commits

...

7 commits

Author SHA1 Message Date
0e926a34ba font: extensive tweaks, looks much better 2026-04-10 06:08:17 +00:00
40a5e6789c font: fully implemented font changes to UI, size/spacing need tweaking 2026-04-10 06:08:17 +00:00
0257791e4d font: tweak sizes of stats 2026-04-10 06:08:17 +00:00
2fdebb8f41 render: implement experimental font change, needs work 2026-04-10 06:08:17 +00:00
raf
09f7e659b5 Merge pull request 'various: implement fog of war; make enemy AI slightly more intelligent' (#14) from notashelf/push-wlxxmonulyzt into main
Reviewed-on: #14
Reviewed-by: A.M. Rowsell <amr@noreply.localhost>
2026-04-10 06:07:57 +00:00
71343311eb
enemy: add alert memory; vision variance based on type
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I2f5c7cac72c8772e5871b99026d106b46a6a6964
2026-04-09 21:28:18 +03:00
f85d28e932
various: implement fog of war; make enemy AI slightly more intelligent
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I3e22dbc5e10690871255980c52a24c226a6a6964
2026-04-09 21:28:17 +03:00
11 changed files with 341 additions and 94 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -34,6 +34,8 @@ typedef struct {
TileType tiles[MAP_HEIGHT][MAP_WIDTH]; TileType tiles[MAP_HEIGHT][MAP_WIDTH];
Room rooms[MAX_ROOMS]; Room rooms[MAX_ROOMS];
int room_count; int room_count;
unsigned char visible[MAP_HEIGHT][MAP_WIDTH];
unsigned char remembered[MAP_HEIGHT][MAP_WIDTH];
} Map; } Map;
// Dungeon // Dungeon
@ -102,6 +104,11 @@ typedef struct {
int status_chance; int status_chance;
int crit_chance; // crit chance percentage (0-100) int crit_chance; // crit chance percentage (0-100)
int crit_mult; // crit damage multiplier percentage (e.g. 150 = 1.5x) int crit_mult; // crit damage multiplier percentage (e.g. 150 = 1.5x)
// vision
int vision_range;
int alert; // 1 = aware of player, searching
int last_known_x; // last position where enemy saw player
int last_known_y;
// status effects // status effects
StatusEffect effects[MAX_EFFECTS]; StatusEffect effects[MAX_EFFECTS];
int effect_count; int effect_count;

View file

@ -4,6 +4,7 @@
#include "map.h" #include "map.h"
#include "movement.h" #include "movement.h"
#include "rng.h" #include "rng.h"
#include "settings.h"
#include <string.h> #include <string.h>
// Forward declaration // Forward declaration
@ -69,6 +70,7 @@ void enemy_spawn(Enemy enemies[], int *count, Map *map, Player *p, int floor) {
e.resistance[DMG_PIERCE] = 0; e.resistance[DMG_PIERCE] = 0;
e.resistance[DMG_FIRE] = -25; e.resistance[DMG_FIRE] = -25;
e.resistance[DMG_POISON] = 50; e.resistance[DMG_POISON] = 50;
e.vision_range = 7;
break; break;
case ENEMY_SKELETON: case ENEMY_SKELETON:
e.max_hp = ENEMY_BASE_HP + floor + 2; e.max_hp = ENEMY_BASE_HP + floor + 2;
@ -86,6 +88,7 @@ void enemy_spawn(Enemy enemies[], int *count, Map *map, Player *p, int floor) {
e.resistance[DMG_PIERCE] = 50; e.resistance[DMG_PIERCE] = 50;
e.resistance[DMG_FIRE] = 25; e.resistance[DMG_FIRE] = 25;
e.resistance[DMG_POISON] = 75; e.resistance[DMG_POISON] = 75;
e.vision_range = 6;
break; break;
case ENEMY_ORC: case ENEMY_ORC:
e.max_hp = ENEMY_BASE_HP + floor + 4; e.max_hp = ENEMY_BASE_HP + floor + 4;
@ -103,6 +106,7 @@ void enemy_spawn(Enemy enemies[], int *count, Map *map, Player *p, int floor) {
e.resistance[DMG_PIERCE] = -25; e.resistance[DMG_PIERCE] = -25;
e.resistance[DMG_FIRE] = 0; e.resistance[DMG_FIRE] = 0;
e.resistance[DMG_POISON] = 0; e.resistance[DMG_POISON] = 0;
e.vision_range = 5;
break; break;
default: default:
e.max_hp = ENEMY_BASE_HP; e.max_hp = ENEMY_BASE_HP;
@ -116,6 +120,7 @@ void enemy_spawn(Enemy enemies[], int *count, Map *map, Player *p, int floor) {
e.crit_chance = ENEMY_CRIT_CHANCE; e.crit_chance = ENEMY_CRIT_CHANCE;
e.crit_mult = ENEMY_CRIT_MULT; e.crit_mult = ENEMY_CRIT_MULT;
memset(e.resistance, 0, sizeof(e.resistance)); memset(e.resistance, 0, sizeof(e.resistance));
e.vision_range = ENEMY_VIEW_RANGE;
break; break;
} }
e.cooldown = e.speed; e.cooldown = e.speed;
@ -135,11 +140,9 @@ int is_enemy_at(const Enemy *enemies, int count, int x, int y) {
return 0; return 0;
} }
// Check if enemy can see player (adjacent) // Check if enemy can see player (within view range and line of sight)
static int can_see_player(Enemy *e, Player *p) { static int can_see_player(Enemy *e, Player *p, Map *map) {
int dx = p->position.x - e->position.x; return can_see_entity(map, e->position.x, e->position.y, p->position.x, p->position.y, e->vision_range);
int dy = p->position.y - e->position.y;
return (dx >= -1 && dx <= 1 && dy >= -1 && dy <= 1);
} }
@ -171,7 +174,88 @@ static void enemy_move_toward_player(Enemy *e, Player *p, Map *map, Enemy *all_e
} }
} }
// Perform a single action for an enemy (attack if adjacent, otherwise move) // Move enemy in a random direction (patrol)
static void enemy_patrol(Enemy *e, Map *map, Enemy *all_enemies, int enemy_count) {
if (rng_int(0, 100) > ENEMY_PATROL_MOVE_CHANCE)
return;
int dx = rng_int(-1, 1);
int dy = rng_int(-1, 1);
if (dx == 0 && dy == 0)
return;
int new_x = e->position.x + dx;
int new_y = e->position.y + dy;
if (is_floor(map, new_x, new_y) && !is_enemy_at(all_enemies, enemy_count, new_x, new_y)) {
e->position.x = new_x;
e->position.y = new_y;
}
}
// Move enemy toward last known player position
static void enemy_move_to_last_known(Enemy *e, Map *map, Enemy *all_enemies, int enemy_count) {
int dx = 0, dy = 0;
if (e->last_known_x > e->position.x)
dx = 1;
else if (e->last_known_x < e->position.x)
dx = -1;
if (e->last_known_y > e->position.y)
dy = 1;
else if (e->last_known_y < e->position.y)
dy = -1;
int new_x = e->position.x + dx;
int new_y = e->position.y;
if (dx != 0 && is_floor(map, new_x, new_y) && !is_enemy_at(all_enemies, enemy_count, new_x, new_y)) {
e->position.x = new_x;
} else if (dy != 0) {
new_x = e->position.x;
new_y = e->position.y + dy;
if (is_floor(map, new_x, new_y) && !is_enemy_at(all_enemies, enemy_count, new_x, new_y)) {
e->position.x = new_x;
e->position.y = new_y;
}
}
if (e->position.x == e->last_known_x && e->position.y == e->last_known_y)
e->alert = 0;
}
// Check if position is within alert radius of another enemy
static int is_nearby_enemy(const Enemy *enemies, int count, int x, int y, int radius) {
for (int i = 0; i < count; i++) {
if (!enemies[i].alive)
continue;
int dx = enemies[i].position.x - x;
int dy = enemies[i].position.y - y;
if (dx * dx + dy * dy <= radius * radius)
return 1;
}
return 0;
}
// Propagate alert to nearby enemies
static void propagate_alert(Enemy *trigger_enemy, Enemy *all_enemies, int enemy_count) {
for (int i = 0; i < enemy_count; i++) {
Enemy *e = &all_enemies[i];
if (!e->alive || e == trigger_enemy)
continue;
if (e->alert)
continue;
if (is_nearby_enemy(all_enemies, enemy_count, e->position.x, e->position.y, 5)) {
e->alert = 1;
e->last_known_x = trigger_enemy->last_known_x;
e->last_known_y = trigger_enemy->last_known_y;
}
}
}
// Perform a single action for an enemy (attack if visible, otherwise patrol or search)
void enemy_act(Enemy *e, Player *p, Map *map, Enemy *all_enemies, int enemy_count) { void enemy_act(Enemy *e, Player *p, Map *map, Enemy *all_enemies, int enemy_count) {
if (!e->alive) if (!e->alive)
return; return;
@ -180,14 +264,37 @@ void enemy_act(Enemy *e, Player *p, Map *map, Enemy *all_enemies, int enemy_coun
if (combat_has_effect(e->effects, e->effect_count, EFFECT_STUN)) if (combat_has_effect(e->effects, e->effect_count, EFFECT_STUN))
return; return;
// Check if adjacent to player - attack int can_see = can_see_player(e, p, map);
if (can_see_player(e, p)) {
// If we can see the player, update alert state and last known position
if (can_see) {
e->alert = 1;
e->last_known_x = p->position.x;
e->last_known_y = p->position.y;
}
// Attack if adjacent to player
if (can_see && can_see_entity(map, e->position.x, e->position.y, p->position.x, p->position.y, 1)) {
combat_enemy_attack(e, p); combat_enemy_attack(e, p);
propagate_alert(e, all_enemies, enemy_count);
return; return;
} }
// Otherwise, move toward player // Move toward player if visible
enemy_move_toward_player(e, p, map, all_enemies, enemy_count); if (can_see) {
enemy_move_toward_player(e, p, map, all_enemies, enemy_count);
propagate_alert(e, all_enemies, enemy_count);
return;
}
// If alert but can't see player, move toward last known position
if (e->alert) {
enemy_move_to_last_known(e, map, all_enemies, enemy_count);
return;
}
// Not alert - patrol randomly
enemy_patrol(e, map, all_enemies, enemy_count);
} }
void enemy_update_all(Enemy enemies[], int count, Player *p, Map *map) { void enemy_update_all(Enemy enemies[], int count, Player *p, Map *map) {

View file

@ -123,6 +123,9 @@ static void init_floor(GameState *gs, int floor_num) {
} }
gs->player.floor = floor_num; gs->player.floor = floor_num;
// Calculate initial visibility
calculate_visibility(&gs->map, gs->player.position.x, gs->player.position.y);
// Spawn enemies // Spawn enemies
enemy_spawn(gs->enemies, &gs->enemy_count, &gs->map, &gs->player, floor_num); enemy_spawn(gs->enemies, &gs->enemy_count, &gs->map, &gs->player, floor_num);
@ -217,6 +220,9 @@ static void post_action(GameState *gs, Enemy *attacked_enemy) {
} }
} }
// Update visibility based on player's new position
calculate_visibility(&gs->map, gs->player.position.x, gs->player.position.y);
// Enemy turns - uses speed/cooldown system // Enemy turns - uses speed/cooldown system
enemy_update_all(gs->enemies, gs->enemy_count, &gs->player, &gs->map); enemy_update_all(gs->enemies, gs->enemy_count, &gs->player, &gs->map);
@ -248,6 +254,7 @@ static int handle_stun_turn(GameState *gs) {
if (gs->game_over) if (gs->game_over)
return 1; return 1;
enemy_update_all(gs->enemies, gs->enemy_count, &gs->player, &gs->map); enemy_update_all(gs->enemies, gs->enemy_count, &gs->player, &gs->map);
calculate_visibility(&gs->map, gs->player.position.x, gs->player.position.y);
if (gs->player.hp <= 0) if (gs->player.hp <= 0)
gs->game_over = 1; gs->game_over = 1;
gs->last_message = "You are stunned!"; gs->last_message = "You are stunned!";
@ -504,7 +511,11 @@ void load_audio_assets(GameState *gs) {
static void game_loop(void) { static void game_loop(void) {
GameState gs; GameState gs;
memset(&gs, 0, sizeof(GameState)); memset(&gs, 0, sizeof(GameState));
// load external assets
// sound
load_audio_assets(&gs); load_audio_assets(&gs);
// font
Font fontTTF = LoadFontEx("./assets/fonts/Tomorrow_Night.ttf", 24, NULL, 0);
// Initialize first floor // Initialize first floor
rng_seed(12345); rng_seed(12345);
init_floor(&gs, 1); init_floor(&gs, 1);
@ -550,26 +561,26 @@ static void game_loop(void) {
cam.offset = (Vector2){(float)gs.shake_x, (float)gs.shake_y}; cam.offset = (Vector2){(float)gs.shake_x, (float)gs.shake_y};
BeginMode2D(cam); BeginMode2D(cam);
render_map(&gs.map); render_map(&gs.map);
render_items(gs.items, gs.item_count); render_items(gs.items, gs.item_count, gs.map.visible);
render_enemies(gs.enemies, gs.enemy_count); render_enemies(gs.enemies, gs.enemy_count, gs.map.visible);
render_player(&gs.player); render_player(&gs.player);
EndMode2D(); EndMode2D();
// Floating texts follow world shake // Floating texts follow world shake
render_floating_texts(gs.floating_texts, gs.floating_count, gs.shake_x, gs.shake_y); 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 // Draw action log
render_action_log(gs.action_log, gs.log_count, gs.log_head); render_action_log(gs.action_log, gs.log_count, gs.log_head, &fontTTF);
// Draw inventory overlay if active // Draw inventory overlay if active
if (gs.show_inventory) { if (gs.show_inventory) {
render_inventory_overlay(&gs.player, gs.inv_selected); render_inventory_overlay(&gs.player, gs.inv_selected, &fontTTF);
} }
// Draw message if any // Draw message if any
if (gs.last_message != NULL && gs.message_timer > 0) { if (gs.last_message != NULL && gs.message_timer > 0) {
render_message(gs.last_message); render_message(gs.last_message, &fontTTF);
} }
// Draw game over screen // Draw game over screen
@ -582,7 +593,7 @@ static void game_loop(void) {
} }
render_end_screen(gs.game_won, gs.total_kills, gs.items_collected, gs.damage_dealt, gs.damage_taken, render_end_screen(gs.game_won, gs.total_kills, gs.items_collected, gs.damage_dealt, gs.damage_taken,
gs.crits_landed, gs.times_hit, gs.potions_used, gs.floors_reached, gs.turn_count, gs.crits_landed, gs.times_hit, gs.potions_used, gs.floors_reached, gs.turn_count,
gs.final_score); gs.final_score, &fontTTF);
} }
EndDrawing(); EndDrawing();

View file

@ -1,6 +1,8 @@
#include "map.h" #include "map.h"
#include "rng.h" #include "rng.h"
#include "settings.h"
#include "utils.h" #include "utils.h"
#include <stdlib.h>
#include <string.h> #include <string.h>
void map_init(Map *map) { void map_init(Map *map) {
@ -10,6 +12,8 @@ void map_init(Map *map) {
map->tiles[y][x] = TILE_WALL; map->tiles[y][x] = TILE_WALL;
} }
} }
memset(map->visible, 0, sizeof(map->visible));
memset(map->remembered, 0, sizeof(map->remembered));
map->room_count = 0; map->room_count = 0;
} }
@ -186,3 +190,67 @@ void dungeon_generate(Dungeon *d, Map *map, int floor_num) {
d->room_count = map->room_count; d->room_count = map->room_count;
memcpy(d->rooms, map->rooms, sizeof(Room) * map->room_count); memcpy(d->rooms, map->rooms, sizeof(Room) * map->room_count);
} }
int is_in_view_range(int x, int y, int view_x, int view_y, int range) {
int dx = x - view_x;
int dy = y - view_y;
return (dx * dx + dy * dy) <= (range * range);
}
static int trace_line_of_sight(const Map *map, int x1, int y1, int x2, int y2) {
int dx = abs(x2 - x1);
int dy = abs(y2 - y1);
int sx = (x1 < x2) ? 1 : -1;
int sy = (y1 < y2) ? 1 : -1;
int err = dx - dy;
int x = x1;
int y = y1;
while (1) {
if (!in_bounds(x, y, MAP_WIDTH, MAP_HEIGHT))
return 0;
if (x == x2 && y == y2)
return 1;
if (map->tiles[y][x] == TILE_WALL && !(x == x1 && y == y1))
return 0;
int e2 = 2 * err;
if (e2 > -dy) {
err -= dy;
x += sx;
}
if (e2 < dx) {
err += dx;
y += sy;
}
}
}
int has_line_of_sight(const Map *map, int x1, int y1, int x2, int y2) {
if (!in_bounds(x1, y1, MAP_WIDTH, MAP_HEIGHT) || !in_bounds(x2, y2, MAP_WIDTH, MAP_HEIGHT))
return 0;
return trace_line_of_sight(map, x1, y1, x2, y2);
}
int can_see_entity(const Map *map, int from_x, int from_y, int to_x, int to_y, int range) {
if (!is_in_view_range(to_x, to_y, from_x, from_y, range))
return 0;
return has_line_of_sight(map, from_x, from_y, to_x, to_y);
}
void calculate_visibility(Map *map, int x, int y) {
memset(map->visible, 0, sizeof(map->visible));
for (int ty = 0; ty < MAP_HEIGHT; ty++) {
for (int tx = 0; tx < MAP_WIDTH; tx++) {
if (is_in_view_range(tx, ty, x, y, PLAYER_VIEW_RANGE)) {
if (has_line_of_sight(map, x, y, tx, ty)) {
map->visible[ty][tx] = 1;
map->remembered[ty][tx] = 1;
}
}
}
}
}

View file

@ -18,4 +18,10 @@ void map_init(Map *map);
// Get a random floor tile position // Get a random floor tile position
void get_random_floor_tile(Map *map, int *x, int *y, int attempts); void get_random_floor_tile(Map *map, int *x, int *y, int attempts);
// Visibility / Fog of War
int is_in_view_range(int x, int y, int view_x, int view_y, int range);
int has_line_of_sight(const Map *map, int x1, int y1, int x2, int y2);
void calculate_visibility(Map *map, int x, int y);
int can_see_entity(const Map *map, int from_x, int from_y, int to_x, int to_y, int range);
#endif // MAP_H #endif // MAP_H

View file

@ -11,18 +11,31 @@ void render_map(const Map *map) {
for (int y = 0; y < MAP_HEIGHT; y++) { for (int y = 0; y < MAP_HEIGHT; y++) {
for (int x = 0; x < MAP_WIDTH; x++) { for (int x = 0; x < MAP_WIDTH; x++) {
Rectangle rect = {(float)(x * TILE_SIZE), (float)(y * TILE_SIZE), (float)TILE_SIZE, (float)TILE_SIZE}; Rectangle rect = {(float)(x * TILE_SIZE), (float)(y * TILE_SIZE), (float)TILE_SIZE, (float)TILE_SIZE};
int visible = map->visible[y][x];
int remembered = map->remembered[y][x];
if (!visible && !remembered) {
DrawRectangleRec(rect, (Color){5, 5, 10, 255});
continue;
}
Color wall_color = visible ? DARKGRAY : (Color){25, 25, 30, 255};
Color floor_color = visible ? BLACK : (Color){15, 15, 20, 255};
Color stairs_color = visible ? (Color){100, 100, 100, 255} : (Color){40, 40, 45, 255};
switch (map->tiles[y][x]) { switch (map->tiles[y][x]) {
case TILE_WALL: case TILE_WALL:
DrawRectangleRec(rect, DARKGRAY); DrawRectangleRec(rect, wall_color);
break; break;
case TILE_FLOOR: case TILE_FLOOR:
DrawRectangleRec(rect, BLACK); DrawRectangleRec(rect, floor_color);
break; break;
case TILE_STAIRS: case TILE_STAIRS:
DrawRectangleRec(rect, (Color){100, 100, 100, 255}); DrawRectangleRec(rect, stairs_color);
// Draw stairs marker if (visible)
DrawText(">", x * TILE_SIZE + 4, y * TILE_SIZE + 2, 12, WHITE); DrawText(">", x * TILE_SIZE + 4, y * TILE_SIZE + 2, 12, WHITE);
else
DrawText(">", x * TILE_SIZE + 4, y * TILE_SIZE + 2, 12, (Color){60, 60, 65, 255});
break; break;
} }
} }
@ -35,10 +48,12 @@ void render_player(const Player *p) {
DrawRectangleRec(rect, BLUE); DrawRectangleRec(rect, BLUE);
} }
void render_enemies(const Enemy *enemies, int count) { void render_enemies(const Enemy *enemies, int count, const unsigned char visible[MAP_HEIGHT][MAP_WIDTH]) {
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
if (!enemies[i].alive) if (!enemies[i].alive)
continue; continue;
if (!visible[enemies[i].position.y][enemies[i].position.x])
continue;
Rectangle rect = {(float)(enemies[i].position.x * TILE_SIZE), (float)(enemies[i].position.y * TILE_SIZE), Rectangle rect = {(float)(enemies[i].position.x * TILE_SIZE), (float)(enemies[i].position.y * TILE_SIZE),
(float)TILE_SIZE, (float)TILE_SIZE}; (float)TILE_SIZE, (float)TILE_SIZE};
@ -80,10 +95,12 @@ void render_enemies(const Enemy *enemies, int count) {
} }
} }
void render_items(const Item *items, int count) { void render_items(const Item *items, int count, const unsigned char visible[MAP_HEIGHT][MAP_WIDTH]) {
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
if (items[i].picked_up) if (items[i].picked_up)
continue; continue;
if (!visible[items[i].y][items[i].x])
continue;
Rectangle rect = {(float)(items[i].x * TILE_SIZE), (float)(items[i].y * TILE_SIZE), (float)TILE_SIZE, Rectangle rect = {(float)(items[i].x * TILE_SIZE), (float)(items[i].y * TILE_SIZE), (float)TILE_SIZE,
(float)TILE_SIZE}; (float)TILE_SIZE};
@ -109,7 +126,7 @@ void render_items(const Item *items, int count) {
} }
} }
void render_ui(const Player *p) { void render_ui(const Player *p, Font *font) {
// HUD Panel // HUD Panel
const int hud_y = MAP_HEIGHT * TILE_SIZE; const int hud_y = MAP_HEIGHT * TILE_SIZE;
const int hud_height = 60; const int hud_height = 60;
@ -153,7 +170,7 @@ void render_ui(const Player *p) {
int bar_height = 16; int bar_height = 16;
// HP Label, above bar // HP Label, above bar
DrawText("HP", bar_x, bar_y - 11, 9, text_dim); DrawTextEx(*font, "HP", (Vector2){bar_x, bar_y - 17}, BIG_FONT, NAR_CHAR_SPACE, text_dim);
// HP Bar background // HP Bar background
DrawRectangle(bar_x, bar_y, bar_width, bar_height, (Color){20, 15, 15, 255}); DrawRectangle(bar_x, bar_y, bar_width, bar_height, (Color){20, 15, 15, 255});
@ -178,8 +195,9 @@ void render_ui(const Player *p) {
// HP text, centered in bar // HP text, centered in bar
char hp_text[32]; char hp_text[32];
snprintf(hp_text, sizeof(hp_text), "%d/%d", p->hp, p->max_hp); snprintf(hp_text, sizeof(hp_text), "%d/%d", p->hp, p->max_hp);
int hp_text_w = MeasureText(hp_text, 10); int hp_text_w = MeasureText(hp_text, 12);
DrawText(hp_text, bar_x + (bar_width - hp_text_w) / 2, bar_y + 2, 10, 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 // Status effects
int effect_x = bar_x; int effect_x = bar_x;
@ -214,7 +232,7 @@ void render_ui(const Player *p) {
if (p->effects[i].duration > 0) { if (p->effects[i].duration > 0) {
char eff_text[16]; char eff_text[16];
snprintf(eff_text, sizeof(eff_text), "%s%d", eff_label, p->effects[i].duration); 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}, SMALL_FONT, NAR_CHAR_SPACE, eff_color);
effect_x += 28; effect_x += 28;
} }
} }
@ -226,65 +244,68 @@ void render_ui(const Player *p) {
// Floor // Floor
char floor_text[16]; char floor_text[16];
snprintf(floor_text, sizeof(floor_text), "F%d", p->floor); snprintf(floor_text, sizeof(floor_text), "F%d", p->floor);
DrawText(floor_text, stats_x, stats_y, 14, text_bright); DrawTextEx(*font, floor_text, (Vector2){stats_x, stats_y}, 16, NORM_CHAR_SPACE, text_bright);
DrawText("Floor", stats_x, stats_y + 16, 9, text_dim); DrawTextEx(*font, "Floor", (Vector2){stats_x, stats_y + 16}, 12, NAR_CHAR_SPACE, text_dim);
// ATK // ATK
char atk_text[16]; char atk_text[16];
snprintf(atk_text, sizeof(atk_text), "%d", p->attack); snprintf(atk_text, sizeof(atk_text), "%d", p->attack);
DrawText(atk_text, stats_x + stat_spacing, stats_y, 14, YELLOW); DrawTextEx(*font, atk_text, (Vector2){stats_x + stat_spacing, stats_y}, 16, NORM_CHAR_SPACE, YELLOW);
DrawText("ATK", stats_x + stat_spacing, stats_y + 16, 9, text_dim); DrawTextEx(*font, "ATK", (Vector2){stats_x + stat_spacing, stats_y + 16}, 12, NAR_CHAR_SPACE, text_dim);
// DEF // DEF
char def_text[16]; char def_text[16];
snprintf(def_text, sizeof(def_text), "%d", p->defense); 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}); DrawTextEx(*font, def_text, (Vector2){stats_x + stat_spacing * 2, stats_y}, 16, NORM_CHAR_SPACE,
DrawText("DEF", stats_x + stat_spacing * 2, stats_y + 16, 9, text_dim); (Color){100, 150, 255, 255});
DrawTextEx(*font, "DEF", (Vector2){stats_x + stat_spacing * 2, stats_y + 16}, 12, NAR_CHAR_SPACE, text_dim);
int equip_x = section2_end + 15; int equip_x = section2_end + 15;
int equip_y = hud_y + 8; int equip_y = hud_y + 8;
// Weapon slot // Weapon slot
DrawText("WEAPON", equip_x, equip_y, 9, text_dim); DrawTextEx(*font, "WEAPON", (Vector2){equip_x, equip_y}, MEDIUM_FONT, NAR_CHAR_SPACE, text_dim);
if (p->has_weapon) { if (p->has_weapon) {
const char *weapon_name = item_get_name(&p->equipped_weapon); const char *weapon_name = item_get_name(&p->equipped_weapon);
if (weapon_name) { if (weapon_name) {
char weapon_text[64]; char weapon_text[64];
snprintf(weapon_text, sizeof(weapon_text), "%s +%d [%s]", weapon_name, p->equipped_weapon.power, snprintf(weapon_text, sizeof(weapon_text), "%s +%d [%s]", weapon_name, p->equipped_weapon.power,
dmg_class_get_short(p->equipped_weapon.dmg_class)); dmg_class_get_short(p->equipped_weapon.dmg_class));
DrawText(weapon_text, equip_x, equip_y + 11, 10, (Color){255, 220, 100, 255}); DrawTextEx(*font, weapon_text, (Vector2){equip_x, equip_y + 11}, 10, NAR_CHAR_SPACE, (Color){255, 220, 100, 255});
} }
} else { } else {
DrawText("None [IMP]", equip_x, equip_y + 11, 10, (Color){80, 75, 70, 255}); DrawTextEx(*font, "None [IMP]", (Vector2){equip_x, equip_y + 11}, 10, NAR_CHAR_SPACE, (Color){80, 75, 70, 255});
} }
// Armor slot // Armor slot
DrawText("ARMOR", equip_x, equip_y + 26, 9, text_dim); DrawTextEx(*font, "ARMOR", (Vector2){equip_x, equip_y + 26}, MEDIUM_FONT, NAR_CHAR_SPACE, text_dim);
if (p->has_armor) { if (p->has_armor) {
const char *armor_name = item_get_name(&p->equipped_armor); const char *armor_name = item_get_name(&p->equipped_armor);
if (armor_name) { if (armor_name) {
char armor_text[48]; char armor_text[48];
snprintf(armor_text, sizeof(armor_text), "%s +%d", armor_name, p->equipped_armor.power); snprintf(armor_text, sizeof(armor_text), "%s +%d", armor_name, p->equipped_armor.power);
DrawText(armor_text, equip_x, equip_y + 37, 10, (Color){100, 150, 255, 255}); DrawTextEx(*font, armor_text, (Vector2){equip_x, equip_y + 37}, 10, NAR_CHAR_SPACE, (Color){100, 150, 255, 255});
} }
} else { } else {
DrawText("None", equip_x, equip_y + 37, 10, (Color){80, 75, 70, 255}); DrawTextEx(*font, "None", (Vector2){equip_x, equip_y + 37}, 10, NAR_CHAR_SPACE, (Color){80, 75, 70, 255});
} }
int ctrl_x = section3_end + 20; int ctrl_x = section3_end + 20;
int ctrl_y = hud_y + 14; int ctrl_y = hud_y + 14;
DrawText("[WASD] Move [G] Pickup [I] Inventory [U] Use", ctrl_x, ctrl_y, 11, (Color){139, 119, 89, 255}); DrawTextEx(*font, "[WASD] Move [G] Pickup [I] Inventory [U] Use", (Vector2){ctrl_x, ctrl_y}, MEDIUM_FONT,
DrawText("[E] Equip [D] Drop [Q] Quit", ctrl_x, ctrl_y + 16, 11, (Color){139, 119, 89, 255}); 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 // INV count in top-right corner of HUD
char inv_text[16]; char inv_text[16];
snprintf(inv_text, sizeof(inv_text), "INV: %d/%d", p->inventory_count, MAX_INVENTORY); snprintf(inv_text, sizeof(inv_text), "INV: %d/%d", p->inventory_count, MAX_INVENTORY);
int inv_width = MeasureText(inv_text, 10); int inv_width = MeasureText(inv_text, 10);
DrawText(inv_text, SCREEN_WIDTH - inv_width - 10, hud_y + 5, 10, GREEN); DrawTextEx(*font, inv_text, (Vector2){SCREEN_WIDTH - inv_width - 10, hud_y + 5}, 10, NAR_CHAR_SPACE, GREEN);
} }
void render_action_log(const char log[5][128], int count, int head) { void render_action_log(const char log[5][128], int count, int head, Font *font) {
// Roguelike scroll/log panel styling // Roguelike scroll/log panel styling
const int log_width = 250; const int log_width = 250;
const int log_height = 90; const int log_height = 90;
@ -306,7 +327,8 @@ void render_action_log(const char log[5][128], int count, int head) {
// Title bar // Title bar
DrawRectangle(log_x + 4, log_y + 4, log_width - 8, 16, (Color){30, 25, 20, 255}); DrawRectangle(log_x + 4, log_y + 4, log_width - 8, 16, (Color){30, 25, 20, 255});
DrawText("MESSAGE LOG", log_x + 8, log_y + 6, 10, (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 // Separator line under title
DrawLine(log_x + 4, log_y + 22, log_x + log_width - 5, log_y + 22, log_border_dark); DrawLine(log_x + 4, log_y + 22, log_x + log_width - 5, log_y + 22, log_border_dark);
@ -331,15 +353,15 @@ void render_action_log(const char log[5][128], int count, int head) {
} else { } else {
text_color = (Color){120, 110, 100, 200}; // oldest: dim text_color = (Color){120, 110, 100, 200}; // oldest: dim
} }
DrawText(log[idx], text_x, text_start_y + i * line_height, 10, text_color); DrawTextEx(*font, log[idx], (Vector2){text_x, text_start_y + i * line_height}, 10, NAR_CHAR_SPACE, text_color);
} }
} }
} }
void render_inventory_overlay(const Player *p, int selected) { void render_inventory_overlay(const Player *p, int selected, Font *font) {
// Overlay dimensions // Overlay dimensions
int ov_width = 360; 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, Rectangle overlay = {(float)(SCREEN_WIDTH - ov_width) / 2, (float)(SCREEN_HEIGHT - ov_height) / 2 - 60,
(float)ov_width, (float)ov_height}; (float)ov_width, (float)ov_height};
DrawRectangleRec(overlay, (Color){12, 12, 12, 252}); DrawRectangleRec(overlay, (Color){12, 12, 12, 252});
@ -348,12 +370,14 @@ void render_inventory_overlay(const Player *p, int selected) {
// Title // Title
const char *title = "INVENTORY"; const char *title = "INVENTORY";
int title_w = MeasureText(title, 24); int title_w = MeasureText(title, 24);
DrawText(title, overlay.x + (overlay.width - title_w) / 2, overlay.y + 12, 24, 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 // Draw each inventory slot
char slot_text[64]; char slot_text[64];
int row_height = 26; int row_height = 26;
int start_y = overlay.y + 50; int start_y = overlay.y + 40;
for (int i = 0; i < MAX_INVENTORY; i++) { for (int i = 0; i < MAX_INVENTORY; i++) {
int y_pos = start_y + (i * row_height); int y_pos = start_y + (i * row_height);
@ -370,7 +394,8 @@ void render_inventory_overlay(const Player *p, int selected) {
// Slot number // Slot number
snprintf(slot_text, sizeof(slot_text), "%d.", i + 1); snprintf(slot_text, sizeof(slot_text), "%d.", i + 1);
DrawText(slot_text, overlay.x + 16, y_pos + 4, 14, (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 // Item name
const char *name = item_get_name(item); const char *name = item_get_name(item);
@ -378,31 +403,31 @@ void render_inventory_overlay(const Player *p, int selected) {
Color name_color = (item->type == ITEM_POTION) ? (Color){255, 140, 140, 255} Color name_color = (item->type == ITEM_POTION) ? (Color){255, 140, 140, 255}
: (item->type == ITEM_WEAPON) ? (Color){255, 255, 140, 255} : (item->type == ITEM_WEAPON) ? (Color){255, 255, 140, 255}
: (Color){140, 140, 255, 255}; : (Color){140, 140, 255, 255};
DrawText(name, overlay.x + 45, y_pos + 4, 14, name_color); DrawTextEx(*font, name, (Vector2){overlay.x + 45, y_pos + 4}, 14, NORM_CHAR_SPACE, name_color);
} }
// Power // Power
snprintf(slot_text, sizeof(slot_text), "+%d", item->power); snprintf(slot_text, sizeof(slot_text), "+%d", item->power);
DrawText(slot_text, overlay.x + 150, y_pos + 4, 14, YELLOW); DrawTextEx(*font, slot_text, (Vector2){overlay.x + 150, y_pos + 4}, 14, NORM_CHAR_SPACE, YELLOW);
// Action // Action
if (item->type == ITEM_POTION) { if (item->type == ITEM_POTION) {
DrawText("[U]se", overlay.x + 200, y_pos + 4, 14, GREEN); DrawTextEx(*font, "[U]se", (Vector2){overlay.x + 200, y_pos + 4}, 14, NORM_CHAR_SPACE, GREEN);
} else { } else {
DrawText("[E]quip [D]rop", overlay.x + 200, y_pos + 4, 14, GOLD); DrawTextEx(*font, "[E]quip [D]rop", (Vector2){overlay.x + 200, y_pos + 4}, 14, NORM_CHAR_SPACE, GOLD);
} }
} else { } else {
// Empty slot // Empty slot
snprintf(slot_text, sizeof(slot_text), "%d.", i + 1); snprintf(slot_text, sizeof(slot_text), "%d.", i + 1);
DrawText(slot_text, overlay.x + 16, y_pos + 4, 14, (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 // Instructions at bottom
const char *hint = "[1-0] Select [E] Equip [U] Use [D] Drop [I/ESC] Close"; const char *hint = "[1-0] Select [E] Equip [U] Use [D] Drop [I/ESC] Close";
int hint_w = MeasureText(hint, 12); Vector2 hint_w = MeasureTextEx(*font, hint, NORM_FONT, NAR_CHAR_SPACE);
DrawText(hint, overlay.x + (overlay.width - hint_w) / 2, overlay.y + overlay.height - 22, 12, DrawTextEx(*font, hint, (Vector2){overlay.x + (overlay.width - hint_w.x) / 2, overlay.y + overlay.height - 22},
(Color){65, 65, 65, 255}); NORM_FONT, NAR_CHAR_SPACE, (Color){80, 80, 80, 255});
} }
static Color label_color(FloatingText *ft, int alpha) { static Color label_color(FloatingText *ft, int alpha) {
@ -490,7 +515,7 @@ void render_floating_texts(FloatingText *texts, int count, int shake_x, int shak
} }
void render_end_screen(int is_victory, int kills, int items, int damage_dealt, int damage_taken, int crits, void render_end_screen(int is_victory, int kills, int items, int damage_dealt, int damage_taken, int crits,
int times_hit, int potions, int floors, int turns, int score) { int times_hit, int potions, int floors, int turns, int score, Font *font) {
// Semi-transparent overlay // Semi-transparent overlay
Rectangle overlay = {0, 0, (float)SCREEN_WIDTH, (float)SCREEN_HEIGHT}; Rectangle overlay = {0, 0, (float)SCREEN_WIDTH, (float)SCREEN_HEIGHT};
DrawRectangleRec(overlay, (Color){0, 0, 0, 210}); DrawRectangleRec(overlay, (Color){0, 0, 0, 210});
@ -500,7 +525,8 @@ void render_end_screen(int is_victory, int kills, int items, int damage_dealt, i
int title_font_size = 60; int title_font_size = 60;
Color title_color = is_victory ? GOLD : RED; Color title_color = is_victory ? GOLD : RED;
int title_width = MeasureText(title, title_font_size); int title_width = MeasureText(title, title_font_size);
DrawText(title, (SCREEN_WIDTH - title_width) / 2, 30, title_font_size, title_color); DrawTextEx(*font, title, (Vector2){(SCREEN_WIDTH - title_width) / 2.0f, 30}, title_font_size, NORM_CHAR_SPACE,
title_color);
// Stats box // Stats box
int box_x = SCREEN_WIDTH / 2 - 200; int box_x = SCREEN_WIDTH / 2 - 200;
@ -520,71 +546,73 @@ void render_end_screen(int is_victory, int kills, int items, int damage_dealt, i
Color value_color = WHITE; Color value_color = WHITE;
// Column 1 // Column 1
DrawText("Kills:", col1_x, row_y, 18, label_color); DrawTextEx(*font, "Kills:", (Vector2){col1_x, row_y}, 18, NORM_CHAR_SPACE, label_color);
snprintf(line, sizeof(line), "%d", kills); snprintf(line, sizeof(line), "%d", kills);
DrawText(line, col1_x + 80, row_y, 18, value_color); DrawTextEx(*font, line, (Vector2){col1_x + 80, row_y}, 18, NORM_CHAR_SPACE, value_color);
row_y += line_height; row_y += line_height;
DrawText("Items:", col1_x, row_y, 18, label_color); DrawTextEx(*font, "Items:", (Vector2){col1_x, row_y}, 18, NORM_CHAR_SPACE, label_color);
snprintf(line, sizeof(line), "%d", items); snprintf(line, sizeof(line), "%d", items);
DrawText(line, col1_x + 80, row_y, 18, value_color); DrawTextEx(*font, line, (Vector2){col1_x + 80, row_y}, 18, NORM_CHAR_SPACE, value_color);
row_y += line_height; row_y += line_height;
DrawText("Damage Dealt:", col1_x, row_y, 18, label_color); DrawTextEx(*font, "Damage Dealt:", (Vector2){col1_x, row_y}, 18, NORM_CHAR_SPACE, label_color);
snprintf(line, sizeof(line), "%d", damage_dealt); snprintf(line, sizeof(line), "%d", damage_dealt);
DrawText(line, col1_x + 140, row_y, 18, value_color); DrawTextEx(*font, line, (Vector2){col1_x + 140, row_y}, 18, NORM_CHAR_SPACE, value_color);
row_y += line_height; row_y += line_height;
DrawText("Damage Taken:", col1_x, row_y, 18, label_color); DrawTextEx(*font, "Damage Taken:", (Vector2){col1_x, row_y}, 18, NORM_CHAR_SPACE, label_color);
snprintf(line, sizeof(line), "%d", damage_taken); snprintf(line, sizeof(line), "%d", damage_taken);
DrawText(line, col1_x + 140, row_y, 18, value_color); DrawTextEx(*font, line, (Vector2){col1_x + 140, row_y}, 18, NORM_CHAR_SPACE, value_color);
row_y += line_height; row_y += line_height;
DrawText("Crits:", col1_x, row_y, 18, label_color); DrawTextEx(*font, "Crits:", (Vector2){col1_x, row_y}, 18, NORM_CHAR_SPACE, label_color);
snprintf(line, sizeof(line), "%d", crits); snprintf(line, sizeof(line), "%d", crits);
DrawText(line, col1_x + 80, row_y, 18, value_color); DrawTextEx(*font, line, (Vector2){col1_x + 80, row_y}, 18, NORM_CHAR_SPACE, value_color);
row_y += line_height; row_y += line_height;
DrawText("Times Hit:", col1_x, row_y, 18, label_color); DrawTextEx(*font, "Times Hit:", (Vector2){col1_x, row_y}, 18, NORM_CHAR_SPACE, label_color);
snprintf(line, sizeof(line), "%d", times_hit); snprintf(line, sizeof(line), "%d", times_hit);
DrawText(line, col1_x + 80, row_y, 18, value_color); DrawTextEx(*font, line, (Vector2){col1_x + 80, row_y}, 18, NORM_CHAR_SPACE, value_color);
row_y += line_height; row_y += line_height;
// Column 2 // Column 2
int col2_row_y = box_y + 20; int col2_row_y = box_y + 20;
DrawText("Potions:", col2_x, col2_row_y, 18, label_color); DrawTextEx(*font, "Potions:", (Vector2){col2_x, col2_row_y}, 18, NORM_CHAR_SPACE, label_color);
snprintf(line, sizeof(line), "%d", potions); snprintf(line, sizeof(line), "%d", potions);
DrawText(line, col2_x + 80, col2_row_y, 18, value_color); DrawTextEx(*font, line, (Vector2){col2_x + 80, col2_row_y}, 18, NORM_CHAR_SPACE, value_color);
col2_row_y += line_height; col2_row_y += line_height;
DrawText("Floors:", col2_x, col2_row_y, 18, label_color); DrawTextEx(*font, "Floors:", (Vector2){col2_x, col2_row_y}, 18, NORM_CHAR_SPACE, label_color);
snprintf(line, sizeof(line), "%d", floors); snprintf(line, sizeof(line), "%d", floors);
DrawText(line, col2_x + 80, col2_row_y, 18, value_color); DrawTextEx(*font, line, (Vector2){col2_x + 80, col2_row_y}, 18, NORM_CHAR_SPACE, value_color);
col2_row_y += line_height; col2_row_y += line_height;
DrawText("Turns:", col2_x, col2_row_y, 18, label_color); DrawTextEx(*font, "Turns:", (Vector2){col2_x, col2_row_y}, 18, NORM_CHAR_SPACE, label_color);
snprintf(line, sizeof(line), "%d", turns); snprintf(line, sizeof(line), "%d", turns);
DrawText(line, col2_x + 80, col2_row_y, 18, value_color); DrawTextEx(*font, line, (Vector2){col2_x + 80, col2_row_y}, 18, NORM_CHAR_SPACE, value_color);
col2_row_y += line_height; col2_row_y += line_height;
// Score: placed below the last row of the longer column (6 items, row_y is already there) // Score: placed below the last row of the longer column (6 items, row_y is already there)
row_y += 10; row_y += 10;
DrawText("SCORE:", col1_x, row_y, 22, GOLD); DrawTextEx(*font, "SCORE:", (Vector2){col1_x, row_y}, 22, NORM_CHAR_SPACE, GOLD);
snprintf(line, sizeof(line), "%d", score); snprintf(line, sizeof(line), "%d", score);
DrawText(line, col1_x + 90, row_y, 22, GOLD); DrawTextEx(*font, line, (Vector2){col1_x + 90, col2_row_y}, 22, NORM_CHAR_SPACE, GOLD);
if (is_victory) { if (is_victory) {
const char *subtitle = "Press R to play again or Q to quit"; const char *subtitle = "Press R to play again or Q to quit";
int sub_width = MeasureText(subtitle, 20); int sub_width = MeasureText(subtitle, 20);
DrawText(subtitle, (SCREEN_WIDTH - sub_width) / 2, SCREEN_HEIGHT - 50, 20, LIGHTGRAY); DrawTextEx(*font, subtitle, (Vector2){(SCREEN_WIDTH - sub_width) / 2.0f, SCREEN_HEIGHT - 50}, 20, NORM_CHAR_SPACE,
LIGHTGRAY);
} else { } else {
const char *subtitle = "Press R to restart or Q to quit"; const char *subtitle = "Press R to restart or Q to quit";
int sub_width = MeasureText(subtitle, 20); int sub_width = MeasureText(subtitle, 20);
DrawText(subtitle, (SCREEN_WIDTH - sub_width) / 2, SCREEN_HEIGHT - 50, 20, LIGHTGRAY); DrawTextEx(*font, subtitle, (Vector2){(SCREEN_WIDTH - sub_width) / 2.0f, SCREEN_HEIGHT - 50}, 20, NORM_CHAR_SPACE,
LIGHTGRAY);
} }
} }
void render_message(const char *message) { void render_message(const char *message, Font *font) {
if (message == NULL) if (message == NULL)
return; return;
@ -653,5 +681,5 @@ void render_message(const char *message) {
text_y = (int)box_y + padding_y; text_y = (int)box_y + padding_y;
} }
DrawText(message, text_x, text_y, font_size, WHITE); DrawTextEx(*font, message, (Vector2){text_x, text_y}, font_size, NORM_CHAR_SPACE, WHITE);
} }

View file

@ -80,28 +80,28 @@ void render_map(const Map *map);
void render_player(const Player *p); void render_player(const Player *p);
// Render all enemies // Render all enemies
void render_enemies(const Enemy *enemies, int count); void render_enemies(const Enemy *enemies, int count, const unsigned char visible[MAP_HEIGHT][MAP_WIDTH]);
// Render all items // Render all items
void render_items(const Item *items, int count); void render_items(const Item *items, int count, const unsigned char visible[MAP_HEIGHT][MAP_WIDTH]);
// Render UI overlay // Render UI overlay
void render_ui(const Player *p); void render_ui(const Player *p, Font *font);
// Render action log (bottom left corner) // Render action log (bottom left corner)
void render_action_log(const char log[5][128], int count, int head); void render_action_log(const char log[5][128], int count, int head, Font *font);
// Render inventory selection overlay // Render inventory selection overlay
void render_inventory_overlay(const Player *p, int selected); void render_inventory_overlay(const Player *p, int selected, Font *font);
// Render floating damage text // Render floating damage text
void render_floating_texts(FloatingText *texts, int count, int shake_x, int shake_y); void render_floating_texts(FloatingText *texts, int count, int shake_x, int shake_y);
// Render end screen (victory or death) with stats breakdown // Render end screen (victory or death) with stats breakdown
void render_end_screen(int is_victory, int kills, int items, int damage_dealt, int damage_taken, int crits, void render_end_screen(int is_victory, int kills, int items, int damage_dealt, int damage_taken, int crits,
int times_hit, int potions, int floors, int turns, int score); int times_hit, int potions, int floors, int turns, int score, Font *font);
// Render a message popup // Render a message popup
void render_message(const char *message); void render_message(const char *message, Font *font);
#endif // RENDER_H #endif // RENDER_H

View file

@ -8,6 +8,21 @@
#define SCREEN_WIDTH (MAP_WIDTH * TILE_SIZE) #define SCREEN_WIDTH (MAP_WIDTH * TILE_SIZE)
#define SCREEN_HEIGHT (MAP_HEIGHT * TILE_SIZE) #define SCREEN_HEIGHT (MAP_HEIGHT * TILE_SIZE)
// 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 // Game Limits
#define MAX_ENEMIES 64 #define MAX_ENEMIES 64
#define MAX_ITEMS 128 #define MAX_ITEMS 128
@ -63,4 +78,9 @@
// Message timer // Message timer
#define MESSAGE_TIMER_DURATION 60 #define MESSAGE_TIMER_DURATION 60
// Visibility / Fog of War
#define PLAYER_VIEW_RANGE 8
#define ENEMY_VIEW_RANGE 6
#define ENEMY_PATROL_MOVE_CHANCE 30
#endif // SETTINGS_H #endif // SETTINGS_H