]> git.mcshandy.xyz Git - barrow_crawler/commitdiff
Save file basics are working good enough for now master
authorRandy McShandy <randy@mcshandy.xyz>
Thu, 12 Jun 2025 01:56:42 +0000 (20:56 -0500)
committerRandy McShandy <randy@mcshandy.xyz>
Thu, 12 Jun 2025 01:56:42 +0000 (20:56 -0500)
bin/posix_BC
src/render_raylib.c
src/structs.c
src/structs.h
todo.md [new file with mode: 0644]

index f2e806d35439e344e71b7844e86e6a1131541e01..d2ca837bc1eb65e83d19bdaa8c61ee5c610c0a89 100755 (executable)
Binary files a/bin/posix_BC and b/bin/posix_BC differ
index 009b8c78217eec5a0c24eefd10029e3627983160..533f49b370a99bfd843697816e8ca43838db88a7 100644 (file)
@@ -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};
 
        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);
   {
     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;
                }
 
                        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);
       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;
       }
       {
         processes[E_SAVE_FILE_SAVE].state = E_FINISHED;
       }
@@ -330,18 +329,19 @@ void control_game_mode()
       {
         processes[E_SAVE_FILE_SAVE].state = E_BAD;
       }
       {
         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];
     {
       ProcessInfo* process = &processes[E_SAVE_FILE_LOAD];
-      process->progress  = 0.0;
       process->state     = E_WAITING;
 
       const int success = load_game();
       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;
       }
       {
         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);
       }
 
       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))
     }
 
                if (IsKeyReleased(KEY_ONE))
@@ -582,9 +583,9 @@ void update_timers()
 {
   for (int t = 0; t < E_STATUS_TIMERS; t++)
   {
 {
   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);
     }
   }
 }
     }
   }
 }
index 877604c8415320b4ad68cbbef9fc8af850e3864d..10e86f3caf78e5ec10beb4d8c7f930c857664704 100644 (file)
@@ -72,10 +72,10 @@ const Mat3 laplacian_kernel =
 
 PlaytimeData playtime;
 
 
 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] =
 };
 
 ProcessInfo processes[E_PROCESSES] =
index fb6d14cee33985879d901dbaaf7cd1e572fd01a0..eb4ff20d0884918a3117c264784abacb27f08a27 100644 (file)
@@ -98,13 +98,13 @@ typedef struct
 {
   float time;
   float max;
 {
   float time;
   float max;
-} TimedStatus;
+} Timer;
 
 typedef enum
 {
 
 typedef enum
 {
-  E_TEXT_FADE_TIME = 0,
+  E_STATUS_TEXT_FADE_TIME = 0,
   E_STATUS_TIMERS
   E_STATUS_TIMERS
-} eTimerStatus;
+} eTimers;
 
 typedef enum
 {
 
 typedef enum
 {
@@ -142,7 +142,7 @@ typedef enum
 extern PlaytimeData playtime;
 
 extern ProcessInfo processes[E_PROCESSES];
 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;
 extern char text_places[E_TEXT_PLACES][64];
 
 extern RD_Opts barrow;
diff --git a/todo.md b/todo.md
new file mode 100644 (file)
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