X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftools.c;h=ebcb47305133d67876d167c04b9d604aa6e40ff8;hb=refs%2Ftags%2F4.3.1.0;hp=2ddbb303472553544cf435e3b2113768cb3cd007;hpb=04e5f3736d715014bb08d7daf8493f96525784f9;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index 2ddbb303..ebcb4730 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1483,6 +1483,29 @@ 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) % xsize; + int y = (ly + yoffset + ysize) % ysize; + int sync_frame = y * xsize + x; + + 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]); } @@ -1973,6 +1996,9 @@ void DrawScreenElementExt(int x, int y, int dx, int dy, int element, int graphic; int frame; + if (element == EL_EMPTY) + element = GfxElementEmpty[lx][ly]; + if (IN_LEV_FIELD(lx, ly)) { SetRandomAnimationValue(lx, ly); @@ -1993,7 +2019,7 @@ void DrawScreenElementExt(int x, int y, int dx, int dy, int element, else // border element { graphic = el2img(element); - frame = getGraphicAnimationFrame(graphic, -1); + frame = getGraphicAnimationFrameXY(graphic, lx, ly); } if (element == EL_EXPANDABLE_WALL) @@ -3934,9 +3960,15 @@ void DrawLevelGraphicAnimationIfNeeded(int x, int y, int graphic) if (!IN_LEV_FIELD(x, y) || !IN_SCR_FIELD(sx, sy)) return; + if (Tile[x][y] == EL_EMPTY) + graphic = el2img(GfxElementEmpty[x][y]); + if (!IS_NEW_FRAME(GfxFrame[x][y], graphic)) return; + if (ANIM_MODE(graphic) & (ANIM_TILED | ANIM_RANDOM_STATIC)) + return; + DrawGraphicAnimation(sx, sy, graphic); #if 1