{
int phase;
- if (mode == ANIM_PINGPONG)
+ if (mode & ANIM_PINGPONG)
{
int max_anim_frames = 2 * frames - 2;
else
phase = (FrameCounter % (delay * frames)) / delay;
- if (mode == ANIM_REVERSE)
+ if (mode & ANIM_REVERSE)
phase = -phase;
return phase;
}
-static int getNewGraphicAnimationFrame(int graphic, int sync_frame)
+int getNewGraphicAnimationFrame(int graphic, int sync_frame)
{
int num_frames = new_graphic_info[graphic].anim_frames;
int delay = new_graphic_info[graphic].anim_delay;
int mode = new_graphic_info[graphic].anim_mode;
- int frame;
+ int frame = 0;
/* animation synchronized with global frame counter, not move position */
if (new_graphic_info[graphic].anim_global_sync || sync_frame < 0)
sync_frame = FrameCounter;
- if (mode & ANIM_PINGPONG) /* use border frames once */
+ if (mode & ANIM_LOOP) /* normal, looping animation */
+ {
+ frame = (sync_frame % (delay * num_frames)) / delay;
+ }
+ else if (mode & ANIM_LINEAR) /* normal, non-looping animation */
+ {
+ frame = sync_frame / delay;
+
+ if (frame > num_frames - 1)
+ frame = num_frames - 1;
+ }
+ else if (mode & ANIM_PINGPONG) /* use border frames once */
{
int max_anim_frames = 2 * num_frames - 2;
frame = (sync_frame % (delay * max_anim_frames)) / delay;
frame = (frame < num_frames ? frame : max_anim_frames - frame - 1);
}
- else /* mode == ANIM_NORMAL || mode == ANIM_REVERSE */
- frame = (sync_frame % (delay * num_frames)) / delay;
if (mode & ANIM_REVERSE) /* use reverse animation direction */
frame = num_frames - frame - 1;
void DrawNewGraphicAnimationExt(int x, int y, int graphic, int mask_mode)
{
+#if 0
int delay = new_graphic_info[graphic].anim_delay;
if (!(FrameCounter % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
+#else
+ if (IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
+#endif
{
int frame = getNewGraphicAnimationFrame(graphic, -1);
Bitmap *src_bitmap = new_graphic_info[graphic].bitmap;
int src_x = new_graphic_info[graphic].src_x;
int src_y = new_graphic_info[graphic].src_y;
+ int offset_x = new_graphic_info[graphic].offset_x;
+ int offset_y = new_graphic_info[graphic].offset_y;
- if (new_graphic_info[graphic].anim_vertical)
- src_y += frame * TILEY;
- else
- src_x += frame * TILEX;
+ src_x += frame * offset_x;
+ src_y += frame * offset_y;
BlitBitmap(src_bitmap, dst_bitmap, src_x, src_y, TILEX, TILEY, x, y);
}
GC drawing_gc = src_bitmap->stored_clip_gc;
int src_x = new_graphic_info[graphic].src_x;
int src_y = new_graphic_info[graphic].src_y;
+ int offset_x = new_graphic_info[graphic].offset_x;
+ int offset_y = new_graphic_info[graphic].offset_y;
- if (new_graphic_info[graphic].anim_vertical)
- src_y += frame * TILEY;
- else
- src_x += frame * TILEX;
+ src_x += frame * offset_x;
+ src_y += frame * offset_y;
SetClipOrigin(src_bitmap, drawing_gc, dest_x - src_x, dest_y - src_y);
BlitBitmapMasked(src_bitmap, d, src_x, src_y, TILEX, TILEY, dest_x, dest_y);
GC drawing_gc;
int src_x;
int src_y;
+ int offset_x;
+ int offset_y;
int width = TILEX, height = TILEY;
int cx = 0, cy = 0;
drawing_gc = src_bitmap->stored_clip_gc;
src_x = new_graphic_info[graphic].src_x;
src_y = new_graphic_info[graphic].src_y;
+ offset_x = new_graphic_info[graphic].offset_x;
+ offset_y = new_graphic_info[graphic].offset_y;
- if (new_graphic_info[graphic].anim_vertical)
- src_y += frame * TILEY;
- else
- src_x += frame * TILEX;
+ src_x += frame * offset_x;
+ src_y += frame * offset_y;
src_x += cx;
src_y += cy;
}
else if (element == EL_SP_ELECTRON)
{
- graphic = GFX2_SP_ELECTRON + getGraphicAnimationPhase(8, 2, ANIM_NORMAL);
+ graphic = GFX2_SP_ELECTRON + getGraphicAnimationPhase(8, 2, ANIM_LOOP);
}
else if (element == EL_MOLE || element == EL_PENGUIN ||
element == EL_PIG || element == EL_DRAGON)
}
else if (element == EL_SATELLITE)
{
- graphic = GFX_SONDE_START + getGraphicAnimationPhase(8, 2, ANIM_NORMAL);
+ graphic = GFX_SONDE_START + getGraphicAnimationPhase(8, 2, ANIM_LOOP);
}
else if (element == EL_ACID)
{
- graphic = GFX_GEBLUBBER + getGraphicAnimationPhase(4, 10, ANIM_NORMAL);
+ graphic = GFX_GEBLUBBER + getGraphicAnimationPhase(4, 10, ANIM_LOOP);
}
else if (element == EL_BD_BUTTERFLY || element == EL_BD_FIREFLY)
{
DrawGraphic(x, y, graphic);
}
+inline static int getFramePosition(int x, int y)
+{
+ int element = Feld[x][y];
+ int frame_pos = -1;
+
+ if (element == EL_QUICKSAND_FULL ||
+ element == EL_MAGIC_WALL_FULL ||
+ element == EL_BD_MAGIC_WALL_FULL)
+ frame_pos = -1;
+ else if (IS_MOVING(x, y) || CAN_MOVE(element) || CAN_FALL(element))
+ frame_pos = ABS(MovPos[x][y]) / (TILEX / 8);
+
+ return frame_pos;
+}
+
+inline static int getGfxAction(int x, int y)
+{
+ int gfx_action = GFX_ACTION_DEFAULT;
+
+ if (GfxAction[x][y] != GFX_ACTION_DEFAULT)
+ gfx_action = GfxAction[x][y];
+ else if (IS_MOVING(x, y))
+ gfx_action = GFX_ACTION_MOVING;
+
+ return gfx_action;
+}
+
void DrawNewScreenElementExt(int x, int y, int dx, int dy, int element,
- int cut_mode, int mask_mode)
+ int cut_mode, int mask_mode)
{
int ux = LEVELX(x), uy = LEVELY(y);
int move_dir = MovDir[ux][uy];
- int move_pos = ABS(MovPos[ux][uy]) / (TILEX / 8);
- int gfx_action = (IS_MOVING(ux,uy) ? GFX_ACTION_MOVING : GFX_ACTION_DEFAULT);
+ int move_pos = getFramePosition(ux, uy);
+ int gfx_action = getGfxAction(ux, uy);
int graphic = el_dir_act2img(element, move_dir, gfx_action);
int frame = getNewGraphicAnimationFrame(graphic, move_pos);
-#if 0
- int phase8 = move_pos;
- int phase4 = phase8 / 2;
- int phase2 = phase8 / 4;
-#endif
if (element == EL_WALL_GROWING)
{
boolean left_stopped = FALSE, right_stopped = FALSE;
- if (!IN_LEV_FIELD(ux-1, uy) || IS_MAUER(Feld[ux-1][uy]))
+ if (!IN_LEV_FIELD(ux - 1, uy) || IS_MAUER(Feld[ux - 1][uy]))
left_stopped = TRUE;
- if (!IN_LEV_FIELD(ux+1, uy) || IS_MAUER(Feld[ux+1][uy]))
+ if (!IN_LEV_FIELD(ux + 1, uy) || IS_MAUER(Feld[ux + 1][uy]))
right_stopped = TRUE;
if (left_stopped && right_stopped)
graphic = IMG_WALL;
else if (left_stopped)
+ {
graphic = IMG_WALL_GROWING_ACTIVE_RIGHT;
+ frame = new_graphic_info[graphic].anim_frames - 1;
+ }
else if (right_stopped)
+ {
graphic = IMG_WALL_GROWING_ACTIVE_LEFT;
+ frame = new_graphic_info[graphic].anim_frames - 1;
+ }
}
#if 0
else if ((element == EL_ROCK ||
graphic += phase2;
}
}
+#endif
else if (IS_AMOEBOID(element) || element == EL_AMOEBA_DRIPPING)
{
- graphic = (element == EL_AMOEBA_DEAD ? GFX_AMOEBE_TOT : GFX_AMOEBE_LEBT);
+ graphic = (element == EL_BD_AMOEBA ? IMG_BD_AMOEBA_PART1 :
+ element == EL_AMOEBA_WET ? IMG_AMOEBA_WET_PART1 :
+ element == EL_AMOEBA_DRY ? IMG_AMOEBA_DRY_PART1 :
+ element == EL_AMOEBA_FULL ? IMG_AMOEBA_FULL_PART1 :
+ IMG_AMOEBA_DEAD_PART1);
+
graphic += (x + 2 * y + 4) % 4;
}
-#endif
if (dx || dy)
DrawNewGraphicShifted(x, y, dx, dy, graphic, frame, cut_mode, mask_mode);
for(x=BX1; x<=BX2; x++)
for(y=BY1; y<=BY2; y++)
- DrawScreenField(x, y);
+ DrawNewScreenField(x, y);
redraw_mask |= REDRAW_FIELD;
}
break;
}
- return IMG_EMPTY_SPACE;
+ return IMG_EMPTY;
#endif
}