From: Holger Schemel Date: Thu, 18 Nov 2021 22:16:32 +0000 (+0100) Subject: added graphics animation mode "tiled" for tiled graphics on elements X-Git-Tag: 4.3.1.0~27 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=fb0df571e1a4207bc756e73f7954e1ba05fa1fad;p=rocksndiamonds.git added graphics animation mode "tiled" for tiled graphics on elements --- diff --git a/src/files.c b/src/files.c index 16fe01ed..9a4999b8 100644 --- a/src/files.c +++ b/src/files.c @@ -11985,6 +11985,7 @@ int get_parameter_value(char *value_raw, char *suffix, int type) string_has_parameter(value, "vertical") ? ANIM_VERTICAL : string_has_parameter(value, "centered") ? ANIM_CENTERED : string_has_parameter(value, "all") ? ANIM_ALL : + string_has_parameter(value, "tiled") ? ANIM_TILED : ANIM_DEFAULT); if (string_has_parameter(value, "once")) diff --git a/src/libgame/system.h b/src/libgame/system.h index 306757a6..90a7fe4f 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -369,6 +369,7 @@ #define ANIM_STATIC_PANEL (1 << 13) #define ANIM_ALL (1 << 14) #define ANIM_ONCE (1 << 15) +#define ANIM_TILED (1 << 16) #define ANIM_DEFAULT ANIM_LOOP diff --git a/src/tools.c b/src/tools.c index 2ddbb303..e16a35ff 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1483,6 +1483,20 @@ int getGraphicAnimationFrame(int graphic, int sync_frame) int getGraphicAnimationFrameXY(int graphic, int lx, int ly) { + if (graphic_info[graphic].anim_mode & ANIM_TILED) + { + struct GraphicInfo *g = &graphic_info[graphic]; + int xsize = MAX(1, g->anim_frames_per_line); + int ysize = MAX(1, g->anim_frames / xsize); + int xoffset = g->anim_start_frame % xsize; + int yoffset = g->anim_start_frame % ysize; + int x = (lx + xoffset) % xsize; + int y = (ly + yoffset) % ysize; + int sync_frame = y * xsize + x; + + return sync_frame % g->anim_frames; + } + return getGraphicAnimationFrame(graphic, GfxFrame[lx][ly]); }