From: Randy McShandy Date: Thu, 12 Jun 2025 01:56:42 +0000 (-0500) Subject: Save file basics are working good enough for now X-Git-Url: http://git.mcshandy.xyz/gitweb.cgi?a=commitdiff_plain;h=77be3f2752d6dcd5d3f75b2ff7f4457a67a514e6;p=barrow_crawler Save file basics are working good enough for now --- diff --git a/bin/posix_BC b/bin/posix_BC index f2e806d..d2ca837 100755 Binary files a/bin/posix_BC and b/bin/posix_BC differ diff --git a/src/render_raylib.c b/src/render_raylib.c index 009b8c7..533f49b 100644 --- a/src/render_raylib.c +++ b/src/render_raylib.c @@ -188,7 +188,7 @@ void drawing_game_mode() Rectangle minimap_dest = {.width = 64.0f*img_export_scale.x, .height = 64.0f*img_export_scale.y, .x = 0.0f, .y = 0.0f}; Rectangle minimap_src = {.width = barrow_texture.width, .height = barrow_texture.height, .x = 0.0f, .y = 0.0f}; - if (timers[E_TEXT_FADE_TIME].time > 0.0f) + if (timers[E_STATUS_TEXT_FADE_TIME].time > 0.0) { const char* text = text_places[E_STATUS_TEXT_PLACE]; DrawText(TextFormat("%s", text), 0, screen_dims.y - 32, 32, GREEN); @@ -314,15 +314,14 @@ void control_game_mode() playtime.cam.position = cam_reset_position; } - if (IsKeyReleased(KEY_F4)) + if (IsKeyReleased(KEY_F4) && timers[E_STATUS_TEXT_FADE_TIME].time == 0) { - processes[E_SAVE_FILE_SAVE].progress = 0.0; + ProcessInfo* process = &processes[E_SAVE_FILE_SAVE]; processes[E_SAVE_FILE_SAVE].state = E_WAITING; const int success = save_game(playtime); - timers[E_TEXT_FADE_TIME].time = timers[E_TEXT_FADE_TIME].max; - if (success == 0 && timers[E_TEXT_FADE_TIME].time == 0.0f) + if ((success == 0) && timers[E_STATUS_TEXT_FADE_TIME].time == 0) { processes[E_SAVE_FILE_SAVE].state = E_FINISHED; } @@ -330,18 +329,19 @@ void control_game_mode() { processes[E_SAVE_FILE_SAVE].state = E_BAD; } + + memcpy(text_places[E_STATUS_TEXT_PLACE], process->info_text[process->state], 64); + timers[E_STATUS_TEXT_FADE_TIME].time = timers[E_STATUS_TEXT_FADE_TIME].max; } - if (IsKeyReleased(KEY_F5)) + if (IsKeyReleased(KEY_F5) && timers[E_STATUS_TEXT_FADE_TIME].time == 0) { ProcessInfo* process = &processes[E_SAVE_FILE_LOAD]; - process->progress = 0.0; process->state = E_WAITING; const int success = load_game(); - timers[E_TEXT_FADE_TIME].time = timers[E_TEXT_FADE_TIME].max; - if (success == 0 && timers[E_TEXT_FADE_TIME].time == 0.0f) + if ((success == 0 ) && timers[E_STATUS_TEXT_FADE_TIME].time == 0.0) { process->state = E_FINISHED; } @@ -351,6 +351,7 @@ void control_game_mode() } memcpy(text_places[E_STATUS_TEXT_PLACE], process->info_text[process->state], 64); + timers[E_STATUS_TEXT_FADE_TIME].time = timers[E_STATUS_TEXT_FADE_TIME].max; } if (IsKeyReleased(KEY_ONE)) @@ -582,9 +583,9 @@ void update_timers() { for (int t = 0; t < E_STATUS_TIMERS; t++) { - if (timers[t].time > 0.0f) + if (timers[t].time > 0) { - timers[t].time = MAX(timers[t].time - (((float)1.0/target_fps) * 1000.0f), 0.0f); + timers[t].time = MAX(timers[t].time - ((1.0/(float)target_fps) * 1000.0f), 0.0f); } } } diff --git a/src/structs.c b/src/structs.c index 877604c..10e86f3 100644 --- a/src/structs.c +++ b/src/structs.c @@ -72,10 +72,10 @@ const Mat3 laplacian_kernel = PlaytimeData playtime; -TimedStatus timers[E_STATUS_TIMERS] = +Timer timers[E_STATUS_TIMERS] = { - /* timer time max */ - /* E_TEXT_FADE_TIME */ { 0.0f, 4000.0f } + /* timer time max */ + /* E_STATUS_TEXT_FADE_TIME */ { 0, 4000 } }; ProcessInfo processes[E_PROCESSES] = diff --git a/src/structs.h b/src/structs.h index fb6d14c..eb4ff20 100644 --- a/src/structs.h +++ b/src/structs.h @@ -98,13 +98,13 @@ typedef struct { float time; float max; -} TimedStatus; +} Timer; typedef enum { - E_TEXT_FADE_TIME = 0, + E_STATUS_TEXT_FADE_TIME = 0, E_STATUS_TIMERS -} eTimerStatus; +} eTimers; typedef enum { @@ -142,7 +142,7 @@ typedef enum extern PlaytimeData playtime; extern ProcessInfo processes[E_PROCESSES]; -extern TimedStatus timers[E_STATUS_TIMERS]; +extern Timer timers[E_STATUS_TIMERS]; extern char text_places[E_TEXT_PLACES][64]; extern RD_Opts barrow; diff --git a/todo.md b/todo.md new file mode 100644 index 0000000..68d072d --- /dev/null +++ b/todo.md @@ -0,0 +1,4 @@ +# TODOS +- Move as much as possible over to data tables +- Write up some nice functions to ease table access +- Main menu