added graphics animation mode "random_static" (unchanged for each tile)
authorHolger Schemel <info@artsoft.org>
Fri, 19 Nov 2021 10:26:43 +0000 (11:26 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 22 Jan 2022 16:58:27 +0000 (17:58 +0100)
src/files.c
src/game.c
src/libgame/system.h
src/main.c
src/main.h
src/tools.c

index 9a4999b857f0408ceca1a105ae73407eeb4aaefe..a0e77bccfc3a6e5a49d7ad78fede30309b05a344 100644 (file)
@@ -11978,6 +11978,7 @@ int get_parameter_value(char *value_raw, char *suffix, int type)
              string_has_parameter(value, "pingpong")   ? ANIM_PINGPONG :
              string_has_parameter(value, "pingpong2")  ? ANIM_PINGPONG2 :
              string_has_parameter(value, "random")     ? ANIM_RANDOM :
+             string_has_parameter(value, "random_static") ? ANIM_RANDOM_STATIC :
              string_has_parameter(value, "ce_value")   ? ANIM_CE_VALUE :
              string_has_parameter(value, "ce_score")   ? ANIM_CE_SCORE :
              string_has_parameter(value, "ce_delay")   ? ANIM_CE_DELAY :
index 0383a35f8e6ec95a6effad4f2659c04e07556611..d4c0402560342f08c47abe16dcef0883906d35f3 100644 (file)
@@ -3878,6 +3878,7 @@ void InitGame(void)
 
     GfxFrame[x][y] = 0;
     GfxRandom[x][y] = INIT_GFX_RANDOM();
+    GfxRandomStatic[x][y] = INIT_GFX_RANDOM();
     GfxElement[x][y] = EL_UNDEFINED;
     GfxAction[x][y] = ACTION_DEFAULT;
     GfxDir[x][y] = MV_NONE;
@@ -15968,6 +15969,7 @@ static ListNode *SaveEngineSnapshotBuffers(void)
 
   SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(GfxFrame));
   SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(GfxRandom));
+  SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(GfxRandomStatic));
   SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(GfxElement));
   SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(GfxAction));
   SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(GfxDir));
index 90a7fe4fe2a7b3160f3a163c4301a506bcf3f3e1..327cba881e18ab2b806c4823691f5056e6b53df4 100644 (file)
 #define ANIM_ALL               (1 << 14)
 #define ANIM_ONCE              (1 << 15)
 #define ANIM_TILED             (1 << 16)
+#define ANIM_RANDOM_STATIC     (1 << 17)
 
 #define ANIM_DEFAULT           ANIM_LOOP
 
index 8dd3712b2d6b4488f851731deec7b082514ec9dd..1d99a74d18e72c32c488b08f34d78f3ccff4f13a 100644 (file)
@@ -67,6 +67,7 @@ int                   PlayerVisit[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
 
 int                    GfxFrame[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
 int                    GfxRandom[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
+int                    GfxRandomStatic[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
 int                    GfxElement[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
 int                    GfxAction[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
 int                    GfxDir[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
index ea915a9ac73cef17e7aabe42a1fff9ee245d2373..14c2e885424fac83e3b2b718245ebe9ea73c2188 100644 (file)
@@ -3738,6 +3738,7 @@ extern int                        PlayerVisit[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
 
 extern int                     GfxFrame[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
 extern int                     GfxRandom[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
+extern int                     GfxRandomStatic[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
 extern int                     GfxElement[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
 extern int                     GfxAction[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
 extern int                     GfxDir[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
index 0271abfc43d83eb615b99fe8663df7cd83e0a5d5..bf79b048d344368bf064bbc992bf98a18c4cf301 100644 (file)
@@ -1496,6 +1496,15 @@ int getGraphicAnimationFrameXY(int graphic, int lx, int ly)
 
     return sync_frame % g->anim_frames;
   }
+  else if (graphic_info[graphic].anim_mode & ANIM_RANDOM_STATIC)
+  {
+    struct GraphicInfo *g = &graphic_info[graphic];
+    int x = (lx + lev_fieldx) % lev_fieldx;
+    int y = (ly + lev_fieldy) % lev_fieldy;
+    int sync_frame = GfxRandomStatic[x][y];
+
+    return sync_frame % g->anim_frames;
+  }
 
   return getGraphicAnimationFrame(graphic, GfxFrame[lx][ly]);
 }
@@ -3951,7 +3960,7 @@ void DrawLevelGraphicAnimationIfNeeded(int x, int y, int graphic)
   if (!IS_NEW_FRAME(GfxFrame[x][y], graphic))
     return;
 
-  if (ANIM_MODE(graphic) & ANIM_TILED)
+  if (ANIM_MODE(graphic) & (ANIM_TILED | ANIM_RANDOM_STATIC))
     return;
 
   DrawGraphicAnimation(sx, sy, graphic);