#define DOUBLE_PLAYER_SPEED(p) (HALVE_MOVE_DELAY((p)->move_delay_value))
#define HALVE_PLAYER_SPEED(p) (DOUBLE_MOVE_DELAY((p)->move_delay_value))
+#define INIT_GFX_RANDOM() (SimpleRND(1000000))
+
/* game button identifiers */
#define GAME_CTRL_ID_STOP 0
#define GAME_CTRL_ID_PAUSE 1
#define NUM_GAME_BUTTONS 6
/* forward declaration for internal use */
+static void ResetGfxAnimation(int, int);
+
static void InitBeltMovement(void);
static void CloseAllOpenTimegates(void);
static void CheckGravityMovement(struct PlayerInfo *);
static struct GadgetInfo *game_gadget[NUM_GAME_BUTTONS];
-#define IS_ANIMATED(g) (graphic_info[g].anim_frames > 1)
-#define IS_LOOP_SOUND(s) (sound_info[s].loop)
-
/* ------------------------------------------------------------------------- */
/* definition of elements that automatically change to other elements after */
GfxFrame[x][y] = 0;
GfxAction[x][y] = ACTION_DEFAULT;
- GfxRandom[x][y] = SimpleRND(1000000);
+ GfxRandom[x][y] = INIT_GFX_RANDOM();
}
}
return position;
}
+static void ResetRandomAnimationValue(int x, int y)
+{
+ int element = Feld[x][y];
+ int graphic = el2img(element);
+
+ /* reset random value not until one full delay cycle has reached */
+ if (ANIM_MODE(graphic) == ANIM_RANDOM &&
+ GfxFrame[x][y] > ANIM_DELAY(graphic))
+ GfxRandom[x][y] = INIT_GFX_RANDOM();
+}
+
+static void ResetGfxAnimation(int x, int y)
+{
+ ResetRandomAnimationValue(x, y);
+
+ GfxFrame[x][y] = 0;
+ GfxAction[x][y] = ACTION_DEFAULT;
+}
+
void InitMovingField(int x, int y, int direction)
{
int element = Feld[x][y];
int newy = y + (direction == MV_UP ? -1 : direction == MV_DOWN ? +1 : 0);
if (!JustStopped[x][y] || direction != MovDir[x][y])
- GfxFrame[x][y] = 0;
+ ResetGfxAnimation(x, y);
MovDir[x][y] = direction;
MovDir[newx][newy] = direction;
if (MovDelay[x][y] == 0) /* initialize element change */
{
MovDelay[x][y] = changing_element[element].change_delay + 1;
- GfxFrame[x][y] = 0;
+
+ ResetGfxAnimation(x, y);
if (changing_element[element].pre_change_function)
changing_element[element].pre_change_function(x, y);
else /* finish element change */
{
Feld[x][y] = changing_element[element].next_element;
- GfxFrame[x][y] = 0;
+
+ ResetGfxAnimation(x, y);
DrawLevelField(x, y);
element = Feld[x][y];
graphic = el2img(element);
+ if (ANIM_MODE(graphic) == ANIM_RANDOM &&
+ IS_NEW_FRAME(GfxFrame[x][y], graphic))
+ ResetRandomAnimationValue(x, y);
+
SetRandomAnimationValue(x, y);
if (IS_INACTIVE(element))
Store[jx][jy] = element;
MovDelay[jx][jy] = 96;
- GfxFrame[jx][jy] = 0;
+
+ ResetGfxAnimation(jx, jy);
if (player->dynamite)
{
void SetRandomAnimationValue(int x, int y)
{
- anim.simple_random_value = GfxRandom[x][y];
+ anim.random_frame = GfxRandom[x][y];
}
inline int getGraphicAnimationFrame(int graphic, int sync_frame)
DrawGraphicExt(dst_bitmap, x, y, graphic, frame);
}
-inline boolean checkDrawGraphicAnimation(int x, int y, int graphic)
+inline boolean checkDrawGraphicAnimation(int sx, int sy, int graphic)
{
- int lx = LEVELX(x), ly = LEVELY(y);
+ int lx = LEVELX(sx), ly = LEVELY(sy);
- return (IN_SCR_FIELD(x, y) &&
- GfxFrame[lx][ly] % graphic_info[graphic].anim_delay == 0);
+ return (IN_SCR_FIELD(sx, sy) && IS_NEW_FRAME(GfxFrame[lx][ly], graphic));
}
-inline boolean checkDrawLevelGraphicAnimation(int x, int y, int graphic)
+inline boolean checkDrawLevelGraphicAnimation(int lx, int ly, int graphic)
{
- return (IN_SCR_FIELD(SCREENX(x), SCREENY(y)) &&
- GfxFrame[x][y] % graphic_info[graphic].anim_delay == 0);
+ int sx = SCREENX(lx), sy = SCREENY(ly);
+
+ return (IN_SCR_FIELD(sx, sy) && IS_NEW_FRAME(GfxFrame[lx][ly], graphic));
}
inline boolean DrawGraphicAnimation(int x, int y, int graphic)
inline void ContinueLevelGraphicAnimation(int x, int y, int graphic)
{
- if (GfxFrame[x][y] % graphic_info[graphic].anim_delay != 0)
+ if (!IS_NEW_FRAME(GfxFrame[x][y], graphic))
return;
DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic);