X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=e868babeec2a4318e6b2bda52a740fb436e5c468;hb=8b04d496646e102dd15710ba091e2f37cadcec5e;hp=4d71c89aa190dddb244c4d818230e530447a6ac9;hpb=a5f961c9d6d0ef7f1b69478b6ec20fbac09548b9;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index 4d71c89a..e868babe 100644 --- a/src/game.c +++ b/src/game.c @@ -2927,10 +2927,9 @@ int NewHiScore() return position; } -inline static int getElementMoveStepsize(int x, int y) +inline static int getElementMoveStepsizeExt(int x, int y, int direction) { int element = Feld[x][y]; - int direction = MovDir[x][y]; int dx = (direction == MV_LEFT ? -1 : direction == MV_RIGHT ? +1 : 0); int dy = (direction == MV_UP ? -1 : direction == MV_DOWN ? +1 : 0); int horiz_move = (dx != 0); @@ -2950,6 +2949,11 @@ inline static int getElementMoveStepsize(int x, int y) return step; } +inline static int getElementMoveStepsize(int x, int y) +{ + return getElementMoveStepsizeExt(x, y, MovDir[x][y]); +} + void InitPlayerGfxAnimation(struct PlayerInfo *player, int action, int dir) { if (player->GfxAction != action || player->GfxDir != dir) @@ -3006,19 +3010,35 @@ static void ResetRandomAnimationValue(int x, int y) void InitMovingField(int x, int y, int direction) { int element = Feld[x][y]; - int move_stepsize = getElementMoveStepsize(x, y); int dx = (direction == MV_LEFT ? -1 : direction == MV_RIGHT ? +1 : 0); int dy = (direction == MV_UP ? -1 : direction == MV_DOWN ? +1 : 0); int newx = x + dx; int newy = y + dy; - boolean is_moving = (move_stepsize != 0); /* moving or being moved */ + boolean is_moving_before, is_moving_after; +#if 0 boolean continues_moving = (WasJustMoving[x][y] && direction == MovDir[x][y]); +#endif - /* reset animation only for moving elements that change direction of moving + /* check if element was/is moving or being moved before/after mode change */ +#if 1 + is_moving_before = WasJustMoving[x][y]; +#else + is_moving_before = (getElementMoveStepsizeExt(x, y, MovDir[x][y]) != 0); +#endif + is_moving_after = (getElementMoveStepsizeExt(x, y, direction) != 0); + + /* reset animation only for moving elements which change direction of moving + or which just started or stopped moving (else CEs with property "can move" / "not moving" are reset each frame) */ #if USE_GFX_RESET_ONLY_WHEN_MOVING - if (is_moving && !continues_moving) +#if 1 + if (is_moving_before != is_moving_after || + direction != MovDir[x][y]) ResetGfxAnimation(x, y); +#else + if ((is_moving_before || is_moving_after) && !continues_moving) + ResetGfxAnimation(x, y); +#endif #else if (!continues_moving) ResetGfxAnimation(x, y); @@ -3026,13 +3046,19 @@ void InitMovingField(int x, int y, int direction) MovDir[x][y] = direction; GfxDir[x][y] = direction; - GfxAction[x][y] = (!is_moving ? ACTION_WAITING : + +#if USE_GFX_RESET_ONLY_WHEN_MOVING + GfxAction[x][y] = (!is_moving_after ? ACTION_WAITING : direction == MV_DOWN && CAN_FALL(element) ? ACTION_FALLING : ACTION_MOVING); +#else + GfxAction[x][y] = (direction == MV_DOWN && CAN_FALL(element) ? + ACTION_FALLING : ACTION_MOVING); +#endif /* this is needed for CEs with property "can move" / "not moving" */ - if (is_moving) + if (is_moving_after) { if (Feld[newx][newy] == EL_EMPTY) Feld[newx][newy] = EL_BLOCKED;