From: Holger Schemel Date: Sun, 8 Oct 2023 11:22:11 +0000 (+0200) Subject: added new animation mode "level_nr" to select frame according to level X-Git-Tag: 4.3.7.0~12 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=eaa66141d6a6bfb5ffd4b75d24e941fc0cf0368c;p=rocksndiamonds.git added new animation mode "level_nr" to select frame according to level This change adds a new animation mode "level_nr" which selects a single animation frame from a number of frames that corresponds to the current level. That is, the first frame is used for the first level, the second frame is used for the second level and so on (overwrapping frames if there are more levels than animation frames). This animation mode can therefore only be used for non-animated game graphics, like walls. So this animation mode can be used to have different graphics in different levels for certain game elements, while still using the same game elements in each level. --- diff --git a/src/anim.c b/src/anim.c index acc71733..808f7c8b 100644 --- a/src/anim.c +++ b/src/anim.c @@ -310,6 +310,12 @@ int getAnimationFrame(int num_frames, int delay, int mode, int start_frame, else frame = gfx.anim_random_frame % num_frames; } + else if (mode & ANIM_LEVEL_NR) // play frames by level number + { + int level_pos = level_nr - leveldir_current->first_level; + + frame = level_pos % num_frames; + } else if (mode & (ANIM_CE_VALUE | ANIM_CE_SCORE | ANIM_CE_DELAY)) { frame = sync_frame % num_frames; diff --git a/src/files.c b/src/files.c index d9addaf1..17a5fa8d 100644 --- a/src/files.c +++ b/src/files.c @@ -11859,6 +11859,7 @@ int get_parameter_value(char *value_raw, char *suffix, int type) string_has_parameter(value, "centered") ? ANIM_CENTERED : string_has_parameter(value, "all") ? ANIM_ALL : string_has_parameter(value, "tiled") ? ANIM_TILED : + string_has_parameter(value, "level_nr") ? ANIM_LEVEL_NR : ANIM_DEFAULT); if (string_has_parameter(value, "once")) diff --git a/src/libgame/system.h b/src/libgame/system.h index 39fd1dfc..f321f217 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -366,17 +366,18 @@ #define ANIM_CE_DELAY (1 << 7) #define ANIM_REVERSE (1 << 8) #define ANIM_OPAQUE_PLAYER (1 << 9) +#define ANIM_LEVEL_NR (1 << 10) // values for special (non game element) animation modes // (not stored in level files -- can be changed, if needed) -#define ANIM_HORIZONTAL (1 << 10) -#define ANIM_VERTICAL (1 << 11) -#define ANIM_CENTERED (1 << 12) -#define ANIM_STATIC_PANEL (1 << 13) -#define ANIM_ALL (1 << 14) -#define ANIM_ONCE (1 << 15) -#define ANIM_TILED (1 << 16) -#define ANIM_RANDOM_STATIC (1 << 17) +#define ANIM_HORIZONTAL (1 << 11) +#define ANIM_VERTICAL (1 << 12) +#define ANIM_CENTERED (1 << 13) +#define ANIM_STATIC_PANEL (1 << 14) +#define ANIM_ALL (1 << 15) +#define ANIM_ONCE (1 << 16) +#define ANIM_TILED (1 << 17) +#define ANIM_RANDOM_STATIC (1 << 18) #define ANIM_DEFAULT ANIM_LOOP