1
0
Fork 0
forked from NotAShelf/rogged

rogged: re-seed on game-over; display seed in game-end screen

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I0178392036902a87b64fde63f5a5f56a6a6a6964
This commit is contained in:
raf 2026-04-10 11:22:17 +03:00
commit 8bbca55b78
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
3 changed files with 16 additions and 8 deletions

View file

@ -482,9 +482,9 @@ static int handle_input(GameState *gs) {
// Check for restart (works during game over)
if (IsKeyPressed(KEY_R) && gs->game_over) {
unsigned int saved_seed = gs->run_seed;
memset(gs, 0, sizeof(GameState));
gs->run_seed = saved_seed;
// Generate a new random seed for the new run
gs->run_seed = (unsigned int)time(NULL);
init_floor(gs, 1);
return 0;
}
@ -539,9 +539,9 @@ static void game_loop(unsigned int run_seed) {
if (IsKeyPressed(KEY_Q))
break;
if (IsKeyPressed(KEY_R)) {
unsigned int saved_seed = gs.run_seed;
memset(&gs, 0, sizeof(GameState));
gs.run_seed = saved_seed;
// Generate a new random seed for the new run
gs.run_seed = (unsigned int)time(NULL);
gs.game_over = 0;
gs.game_won = 0;
load_audio_assets(&gs);
@ -598,7 +598,7 @@ static void game_loop(unsigned int run_seed) {
}
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.final_score);
gs.final_score, gs.run_seed);
}
EndDrawing();

View file

@ -507,7 +507,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,
int times_hit, int potions, int floors, int turns, int score) {
int times_hit, int potions, int floors, int turns, int score, unsigned int seed) {
// Semi-transparent overlay
Rectangle overlay = {0, 0, (float)SCREEN_WIDTH, (float)SCREEN_HEIGHT};
DrawRectangleRec(overlay, (Color){0, 0, 0, 210});
@ -523,7 +523,7 @@ void render_end_screen(int is_victory, int kills, int items, int damage_dealt, i
int box_x = SCREEN_WIDTH / 2 - 200;
int box_y = 110;
int box_w = 400;
int box_h = 320;
int box_h = 350;
DrawRectangle(box_x, box_y, box_w, box_h, (Color){20, 20, 20, 240});
DrawRectangleLines(box_x, box_y, box_w, box_h, (Color){100, 100, 100, 255});
@ -589,7 +589,14 @@ void render_end_screen(int is_victory, int kills, int items, int damage_dealt, i
DrawText("SCORE:", col1_x, row_y, 22, GOLD);
snprintf(line, sizeof(line), "%d", score);
DrawText(line, col1_x + 90, row_y, 22, GOLD);
row_y += 35;
// Seed display
DrawText("SEED:", col1_x, row_y, 18, label_color);
snprintf(line, sizeof(line), "%u", seed);
DrawText(line, col1_x + 60, row_y, 18, END_SEED);
// Instructions
if (is_victory) {
const char *subtitle = "Press R to play again or Q to quit";
int sub_width = MeasureText(subtitle, 20);

View file

@ -68,6 +68,7 @@
#define END_OVERLAY (Color){0, 0, 0, 210}
#define END_BOX_BG (Color){20, 20, 20, 240}
#define END_BOX_BORDER (Color){100, 100, 100, 255}
#define END_SEED (Color){150, 200, 255, 255}
// Portrait placeholder
// FIXME: remove when player sprites are available
@ -99,7 +100,7 @@ void render_floating_texts(FloatingText *texts, int count, int shake_x, int shak
// 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,
int times_hit, int potions, int floors, int turns, int score);
int times_hit, int potions, int floors, int turns, int score, unsigned int seed);
// Render a message popup
void render_message(const char *message);