X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftools.c;h=144bce2afeb7dc36852b81bc32cb66192fe3b405;hb=bf630da36e2e31f963b502752b24b14f28193bde;hp=0872e24bc1fde98a5459eff7dda8fff43ae68293;hpb=e803858fbf06157b1ae1e6c60da0d695cffa8345;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index 0872e24b..144bce2a 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1490,8 +1490,9 @@ int getGraphicAnimationFrameXY(int graphic, int lx, int ly) 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; + // may be needed if screen field is significantly larger than playfield + int x = (lx + xoffset + SCR_FIELDX * xsize) % xsize; + int y = (ly + yoffset + SCR_FIELDY * ysize) % ysize; int sync_frame = y * xsize + x; return sync_frame % g->anim_frames; @@ -1499,14 +1500,19 @@ int getGraphicAnimationFrameXY(int graphic, int lx, int ly) 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; + // may be needed if screen field is significantly larger than playfield + int x = (lx + SCR_FIELDX * lev_fieldx) % lev_fieldx; + int y = (ly + SCR_FIELDY * lev_fieldy) % lev_fieldy; int sync_frame = GfxRandomStatic[x][y]; return sync_frame % g->anim_frames; } + else + { + int sync_frame = (IN_LEV_FIELD(lx, ly) ? GfxFrame[lx][ly] : -1); - return getGraphicAnimationFrame(graphic, GfxFrame[lx][ly]); + return getGraphicAnimationFrame(graphic, sync_frame); + } } void getGraphicSourceBitmap(int graphic, int tilesize, Bitmap **bitmap) @@ -1996,11 +2002,11 @@ 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)) { + if (element == EL_EMPTY) + element = GfxElementEmpty[lx][ly]; + SetRandomAnimationValue(lx, ly); graphic = el_act_dir2img(element, GfxAction[lx][ly], GfxDir[lx][ly]);