X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=eb11ae1dd3ab48305474d6dde21e2371cf31b088;hb=234748b5eb0bc4fe29a36fd25a1d25658f53858a;hp=2c5f0e9aabb2f693c3f3c3da9c6ba06d77c428ad;hpb=2455ce294b0108d3a848467ea9d30d049527a545;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index 2c5f0e9a..eb11ae1d 100644 --- a/src/game.c +++ b/src/game.c @@ -669,12 +669,14 @@ void InitGame() InitGameEngine(); +#if 0 #if DEBUG #if USE_NEW_AMOEBA_CODE printf("Using new amoeba code.\n"); #else printf("Using old amoeba code.\n"); #endif +#endif #endif /* don't play tapes over network */ @@ -734,8 +736,8 @@ void InitGame() player->last_jx = player->last_jy = 0; player->jx = player->jy = 0; - player->shield_passive_time_left = 0; - player->shield_active_time_left = 0; + player->shield_normal_time_left = 0; + player->shield_deadly_time_left = 0; DigField(player, 0, 0, 0, 0, DF_NO_PUSH); SnapField(player, 0, 0); @@ -793,6 +795,7 @@ void InitGame() MovPos[x][y] = MovDir[x][y] = MovDelay[x][y] = 0; Store[x][y] = Store2[x][y] = StorePlayer[x][y] = 0; Frame[x][y] = 0; + GfxAction[x][y] = GFX_ACTION_DEFAULT; AmoebaNr[x][y] = 0; JustStopped[x][y] = 0; Stop[x][y] = FALSE; @@ -1327,8 +1330,11 @@ void InitMovingField(int x, int y, int direction) MovDir[x][y] = direction; MovDir[newx][newy] = direction; + if (Feld[newx][newy] == EL_EMPTY) Feld[newx][newy] = EL_BLOCKED; + + GfxAction[x][y] = GFX_ACTION_MOVING; } void Moving2Blocked(int x, int y, int *goes_to_x, int *goes_to_y) @@ -1439,6 +1445,7 @@ void RemoveMovingField(int x, int y) Feld[newx][newy] = EL_EMPTY; MovPos[oldx][oldy] = MovDir[oldx][oldy] = MovDelay[oldx][oldy] = 0; MovPos[newx][newy] = MovDir[newx][newy] = MovDelay[newx][newy] = 0; + GfxAction[oldx][oldy] = GfxAction[newx][newy] = GFX_ACTION_DEFAULT; DrawLevelField(oldx, oldy); DrawLevelField(newx, newy); @@ -1447,32 +1454,27 @@ void RemoveMovingField(int x, int y) void DrawDynamite(int x, int y) { int sx = SCREENX(x), sy = SCREENY(y); - int graphic = el2gfx(Feld[x][y]); - int phase; + int graphic = el2img(Feld[x][y]); + int frame; if (!IN_SCR_FIELD(sx, sy) || IS_PLAYER(x, y)) return; if (Store[x][y]) - DrawGraphic(sx, sy, el2gfx(Store[x][y])); + DrawGraphic(sx, sy, el2img(Store[x][y]), 0); - if (Feld[x][y] == EL_DYNAMITE_ACTIVE) - { - if ((phase = (96 - MovDelay[x][y]) / 12) > 6) - phase = 6; - } - else - { - if ((phase = ((96 - MovDelay[x][y]) / 6) % 8) > 3) - phase = 7 - phase; - } + frame = getGraphicAnimationFrame(graphic, 96 - MovDelay[x][y]); + + /* + printf("-> %d: %d [%d]\n", graphic, frame, MovDelay[x][y]); + */ if (game.emulation == EMU_SUPAPLEX) - DrawGraphic(sx, sy, GFX_SP_DISK_RED); + DrawGraphic(sx, sy, IMG_SP_DISK_RED, 0); else if (Store[x][y]) - DrawGraphicThruMask(sx, sy, graphic + phase); + DrawGraphicThruMask(sx, sy, graphic, frame); else - DrawGraphic(sx, sy, graphic + phase); + DrawGraphic(sx, sy, graphic, frame); } void CheckDynamite(int x, int y) @@ -1508,7 +1510,8 @@ void CheckDynamite(int x, int y) void Explode(int ex, int ey, int phase, int mode) { int x, y; - int num_phase = 9, delay = (game.emulation == EMU_SUPAPLEX ? 3 : 2); + int num_phase = 9; + int delay = (game.emulation == EMU_SUPAPLEX ? 3 : 2); int last_phase = num_phase * delay; int half_phase = (num_phase / 2) * delay; int first_phase_after_start = EX_PHASE_START + 1; @@ -1699,25 +1702,24 @@ void Explode(int ex, int ey, int phase, int mode) } else if (!(phase % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) { - int graphic = GFX_EXPLOSION; + int graphic = IMG_EXPLOSION; + int frame = (phase / delay - 1); if (game.emulation == EMU_SUPAPLEX) graphic = (Store[x][y] == EL_SP_INFOTRON ? - GFX_SP_EXPLODE_INFOTRON : - GFX_SP_EXPLODE_EMPTY); + IMG_SP_EXPLOSION_INFOTRON : + IMG_SP_EXPLOSION); if (phase == delay) - ErdreichAnbroeckeln(SCREENX(x), SCREENY(y)); - - graphic += (phase / delay - 1); + DrawCrumbledSand(SCREENX(x), SCREENY(y)); if (IS_PFORTE(Store[x][y])) { DrawLevelElement(x, y, Store[x][y]); - DrawGraphicThruMask(SCREENX(x), SCREENY(y), graphic); + DrawGraphicThruMask(SCREENX(x), SCREENY(y), graphic, frame); } else - DrawGraphic(SCREENX(x), SCREENY(y), graphic); + DrawGraphic(SCREENX(x), SCREENY(y), graphic, frame); } } @@ -1828,27 +1830,28 @@ void Blurb(int x, int y) { int element = Feld[x][y]; - if (element != EL_ACID_SPLASHING_LEFT && - element != EL_ACID_SPLASHING_RIGHT) /* start */ + if (element != EL_ACID_SPLASH_LEFT && + element != EL_ACID_SPLASH_RIGHT) /* start */ { PlaySoundLevel(x, y, SND_ACID_SPLASHING); if (IN_LEV_FIELD(x-1, y) && IS_FREE(x-1, y) && (!IN_LEV_FIELD(x-1, y-1) || !CAN_FALL(MovingOrBlocked2Element(x-1, y-1)))) { - Feld[x-1][y] = EL_ACID_SPLASHING_LEFT; + Feld[x-1][y] = EL_ACID_SPLASH_LEFT; } if (IN_LEV_FIELD(x+1, y) && IS_FREE(x+1, y) && (!IN_LEV_FIELD(x+1, y-1) || !CAN_FALL(MovingOrBlocked2Element(x+1, y-1)))) { - Feld[x+1][y] = EL_ACID_SPLASHING_RIGHT; + Feld[x+1][y] = EL_ACID_SPLASH_RIGHT; } } else /* go on */ { - int graphic = - (element == EL_ACID_SPLASHING_LEFT ? GFX_BLURB_LEFT : GFX_BLURB_RIGHT); + int graphic = (element == EL_ACID_SPLASH_LEFT ? + IMG_ACID_SPLASH_LEFT : + IMG_ACID_SPLASH_RIGHT); if (!MovDelay[x][y]) /* initialize animation counter */ MovDelay[x][y] = 9; @@ -1857,7 +1860,11 @@ void Blurb(int x, int y) { MovDelay[x][y]--; if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - DrawGraphic(SCREENX(x), SCREENY(y), graphic+4-MovDelay[x][y]/2); + { + int frame = getGraphicAnimationFrame(graphic, 8 - MovDelay[x][y]); + + DrawGraphic(SCREENX(x), SCREENY(y), graphic, frame); + } if (!MovDelay[x][y]) { @@ -1903,7 +1910,7 @@ static void ToggleBeltSwitch(int x, int y) int belt_nr = getBeltNrFromBeltSwitchElement(element); int belt_dir_nr = (game.belt_dir_nr[belt_nr] + 1) % 4; int belt_dir = belt_move_dir[belt_dir_nr]; - int xx, yy; + int xx, yy, i; if (!IS_BELT_SWITCH(element)) return; @@ -1914,6 +1921,18 @@ static void ToggleBeltSwitch(int x, int y) if (belt_dir_nr == 3) belt_dir_nr = 1; + /* set frame order for belt animation graphic according to belt direction */ + for (i=0; i<3; i++) + { + int element = belt_base_active_element[belt_nr] + i; + int graphic = el2img(element); + + if (belt_dir == MV_LEFT) + new_graphic_info[graphic].anim_mode &= ~ANIM_REVERSE; + else + new_graphic_info[graphic].anim_mode |= ANIM_REVERSE; + } + for (yy=0; yy0 && IS_PLAYER(x-1, y)) || (x 3) - phase = 7 - phase; - if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - DrawGraphic(SCREENX(x), SCREENY(y), el2gfx(element) + phase); + { + int graphic = el2img(element); + int frame = getGraphicAnimationFrame(graphic, MovDelay[x][y] % 8); + + DrawGraphic(SCREENX(x), SCREENY(y), graphic, frame); + } if (MovDelay[x][y] % 4 == 3) { @@ -2946,23 +2962,24 @@ void StartMoving(int x, int y) } } else if (element == EL_SP_ELECTRON) - DrawGraphicAnimation(x, y, GFX2_SP_ELECTRON, 8, 2, ANIM_NORMAL); + DrawGraphicAnimation(x, y, IMG_SP_ELECTRON); else if (element == EL_DRAGON) { int i; int dir = MovDir[x][y]; int dx = (dir == MV_LEFT ? -1 : dir == MV_RIGHT ? +1 : 0); int dy = (dir == MV_UP ? -1 : dir == MV_DOWN ? +1 : 0); - int graphic = (dir == MV_LEFT ? GFX_FLAMMEN_LEFT : - dir == MV_RIGHT ? GFX_FLAMMEN_RIGHT : - dir == MV_UP ? GFX_FLAMMEN_UP : - dir == MV_DOWN ? GFX_FLAMMEN_DOWN : GFX_LEERRAUM); - int phase = FrameCounter % 2; + int graphic = (dir == MV_LEFT ? IMG_FLAMES_LEFT1 : + dir == MV_RIGHT ? IMG_FLAMES_RIGHT1 : + dir == MV_UP ? IMG_FLAMES_UP1 : + dir == MV_DOWN ? IMG_FLAMES_DOWN1 : IMG_EMPTY); + int frame = getGraphicAnimationFrame(graphic, -1); for (i=1; i<=3; i++) { int xx = x + i*dx, yy = y + i*dy; int sx = SCREENX(xx), sy = SCREENY(yy); + int flame_graphic = graphic + (i - 1); if (!IN_LEV_FIELD(xx, yy) || IS_SOLID(Feld[xx][yy]) || Feld[xx][yy] == EL_EXPLOSION) @@ -2979,7 +2996,7 @@ void StartMoving(int x, int y) Feld[xx][yy] = EL_FLAMES; if (IN_SCR_FIELD(sx, sy)) - DrawGraphic(sx, sy, graphic + phase*3 + i-1); + DrawGraphic(sx, sy, flame_graphic, frame); } else { @@ -3034,7 +3051,7 @@ void StartMoving(int x, int y) PlaySoundLevel(newx, newy, SND_PENGUIN_PASSING_EXIT); if (IN_SCR_FIELD(SCREENX(newx), SCREENY(newy))) - DrawGraphicThruMask(SCREENX(newx), SCREENY(newy), el2gfx(element)); + DrawGraphicThruMask(SCREENX(newx),SCREENY(newy), el2img(element), 0); local_player->friends_still_needed--; if (!local_player->friends_still_needed && @@ -3179,7 +3196,7 @@ void StartMoving(int x, int y) else /* element == EL_PACMAN */ { Feld[newx][newy] = EL_EMPTY; - DrawNewLevelField(newx, newy); + DrawLevelField(newx, newy); PlaySoundLevel(x, y, SND_PACMAN_EATING); } } @@ -3198,36 +3215,16 @@ void StartMoving(int x, int y) if (element == EL_BUG || element == EL_SPACESHIP || element == EL_SP_SNIKSNAK) -#if 0 DrawLevelField(x, y); -#else - DrawNewLevelField(x, y); -#endif else if (element == EL_BUG || element == EL_SPACESHIP || element == EL_SP_SNIKSNAK || element == EL_MOLE) -#if 1 DrawLevelField(x, y); -#else - DrawNewLevelField(x, y); -#endif else if (element == EL_BD_BUTTERFLY || element == EL_BD_FIREFLY) -#if 0 - DrawGraphicAnimation(x, y, el2gfx(element), 2, 4, ANIM_NORMAL); -#else - DrawNewGraphicAnimation(x, y, el2img(element)); -#endif + DrawGraphicAnimation(x, y, el2img(element)); else if (element == EL_SATELLITE) -#if 0 - DrawGraphicAnimation(x, y, GFX_SONDE_START, 8, 2, ANIM_NORMAL); -#else - DrawNewGraphicAnimation(x, y, IMG_SATELLITE); -#endif + DrawGraphicAnimation(x, y, IMG_SATELLITE); else if (element == EL_SP_ELECTRON) -#if 0 - DrawGraphicAnimation(x, y, GFX2_SP_ELECTRON, 8, 2, ANIM_NORMAL); -#else - DrawNewGraphicAnimation(x, y, IMG_SP_ELECTRON); -#endif + DrawGraphicAnimation(x, y, IMG_SP_ELECTRON); if (DONT_TOUCH(element)) TestIfBadThingTouchesHero(x, y); @@ -3306,7 +3303,7 @@ void ContinueMoving(int x, int y) yy = y + xy[i][1]; if (IN_LEV_FIELD(xx, yy) && Feld[xx][yy] == EL_SAND) - DrawLevelField(xx, yy); /* for "ErdreichAnbroeckeln()" */ + DrawLevelField(xx, yy); /* for "DrawCrumbledSand()" */ } } @@ -3362,21 +3359,14 @@ void ContinueMoving(int x, int y) MovPos[x][y] = MovDir[x][y] = MovDelay[x][y] = 0; MovDelay[newx][newy] = 0; + GfxAction[newx][newy] = GfxAction[x][y]; /* keep action one frame */ + GfxAction[x][y] = GFX_ACTION_DEFAULT; + if (!CAN_MOVE(element)) MovDir[newx][newy] = 0; - if (element == EL_BUG || element == EL_SPACESHIP || - element == EL_SP_SNIKSNAK || element == EL_PACMAN || - element == EL_SP_ELECTRON) - { - DrawNewLevelField(x, y); - DrawNewLevelField(newx, newy); - } - else - { - DrawLevelField(x, y); - DrawLevelField(newx, newy); - } + DrawLevelField(x, y); + DrawLevelField(newx, newy); Stop[newx][newy] = TRUE; JustStopped[newx][newy] = 3; @@ -3396,12 +3386,10 @@ void ContinueMoving(int x, int y) } else /* still moving on */ { - if (element == EL_BUG || element == EL_SPACESHIP || - element == EL_SP_SNIKSNAK || element == EL_PACMAN || - element == EL_SP_ELECTRON) - DrawNewLevelField(x, y); - else - DrawLevelField(x, y); + if (GfxAction[x][y] == GFX_ACTION_DEFAULT) + GfxAction[x][y] = GFX_ACTION_MOVING; + + DrawLevelField(x, y); } } @@ -3607,7 +3595,12 @@ void AmoebeWaechst(int x, int y) { MovDelay[x][y]--; if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - DrawGraphic(SCREENX(x), SCREENY(y), GFX_AMOEBING + 3 - MovDelay[x][y]/2); + { + int frame = getGraphicAnimationFrame(IMG_AMOEBA_CREATING, + 6 - MovDelay[x][y]); + + DrawGraphic(SCREENX(x), SCREENY(y), IMG_AMOEBA_CREATING, frame); + } if (!MovDelay[x][y]) { @@ -3635,7 +3628,12 @@ void AmoebaDisappearing(int x, int y) { MovDelay[x][y]--; if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - DrawGraphic(SCREENX(x), SCREENY(y), GFX_AMOEBING + MovDelay[x][y]/2); + { + int frame = getGraphicAnimationFrame(IMG_AMOEBA_SHRINKING, + 6 - MovDelay[x][y]); + + DrawGraphic(SCREENX(x), SCREENY(y), IMG_AMOEBA_SHRINKING, frame); + } if (!MovDelay[x][y]) { @@ -3878,7 +3876,12 @@ void RobotWheel(int x, int y) if (MovDelay[x][y]) { if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - DrawGraphic(SCREENX(x), SCREENY(y), GFX_ABLENK+MovDelay[x][y]%4); + { + int frame = getGraphicAnimationFrame(IMG_ROBOT_WHEEL_ACTIVE, -1); + + DrawGraphic(SCREENX(x), SCREENY(y), IMG_ROBOT_WHEEL_ACTIVE, frame); + } + if (!(MovDelay[x][y]%4)) PlaySoundLevel(x, y, SND_ROBOT_WHEEL_ACTIVE); return; @@ -3902,8 +3905,12 @@ void TimegateWheel(int x, int y) if (MovDelay[x][y]) { if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - DrawGraphic(SCREENX(x), SCREENY(y), - GFX_TIMEGATE_SWITCH + MovDelay[x][y]%4); + { + int frame = getGraphicAnimationFrame(IMG_TIMEGATE_SWITCH_ACTIVE, -1); + + DrawGraphic(SCREENX(x), SCREENY(y), IMG_TIMEGATE_SWITCH_ACTIVE, frame); + } + if (!(MovDelay[x][y]%4)) PlaySoundLevel(x, y, SND_TIMEGATE_SWITCH_ACTIVE); return; @@ -3918,10 +3925,7 @@ void TimegateWheel(int x, int y) void Blubber(int x, int y) { - if (y > 0 && IS_MOVING(x, y-1) && MovDir[x][y-1] == MV_DOWN) - DrawLevelField(x, y-1); - else - DrawGraphicAnimation(x, y, GFX_GEBLUBBER, 4, 10, ANIM_NORMAL); + DrawGraphicAnimation(x, y, IMG_ACID); } void NussKnacken(int x, int y) @@ -3933,8 +3937,12 @@ void NussKnacken(int x, int y) { MovDelay[x][y]--; if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - DrawGraphic(SCREENX(x), SCREENY(y), - GFX_CRACKINGNUT + 3 - MovDelay[x][y]/2); + { + int frame = getGraphicAnimationFrame(IMG_NUT_CRACKING, + 6 - MovDelay[x][y]); + + DrawGraphic(SCREENX(x), SCREENY(y), IMG_NUT_CRACKING, frame); + } if (!MovDelay[x][y]) { @@ -3953,8 +3961,12 @@ void BreakingPearl(int x, int y) { MovDelay[x][y]--; if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - DrawGraphic(SCREENX(x), SCREENY(y), - GFX_PEARL_BREAKING + 4 - MovDelay[x][y]/2); + { + int frame = getGraphicAnimationFrame(IMG_PEARL_BREAKING, + 8 - MovDelay[x][y]); + + DrawGraphic(SCREENX(x), SCREENY(y), IMG_PEARL_BREAKING, frame); + } if (!MovDelay[x][y]) { @@ -3964,11 +3976,11 @@ void BreakingPearl(int x, int y) } } -void SiebAktivieren(int x, int y, int typ) +void SiebAktivieren(int x, int y, int type) { - int graphic = (typ == 1 ? GFX_MAGIC_WALL_FULL : GFX_MAGIC_WALL_BD_FULL) + 3; + int graphic = (type == 1 ? IMG_MAGIC_WALL_FULL : IMG_BD_MAGIC_WALL_FULL); - DrawGraphicAnimation(x, y, graphic, 4, 4, ANIM_REVERSE); + DrawGraphicAnimation(x, y, graphic); } void AusgangstuerPruefen(int x, int y) @@ -4006,7 +4018,7 @@ void AusgangstuerOeffnen(int x, int y) int delay = 6; if (!MovDelay[x][y]) /* next animation frame */ - MovDelay[x][y] = 5*delay; + MovDelay[x][y] = 5 * delay; if (MovDelay[x][y]) /* wait some time before next frame */ { @@ -4015,7 +4027,12 @@ void AusgangstuerOeffnen(int x, int y) MovDelay[x][y]--; tuer = MovDelay[x][y]/delay; if (!(MovDelay[x][y]%delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - DrawGraphic(SCREENX(x), SCREENY(y), GFX_AUSGANG_AUF-tuer); + { + int frame = getGraphicAnimationFrame(IMG_EXIT_OPENING, + 29 - MovDelay[x][y]); + + DrawGraphic(SCREENX(x), SCREENY(y), IMG_EXIT_OPENING, frame); + } if (!MovDelay[x][y]) { @@ -4027,7 +4044,7 @@ void AusgangstuerOeffnen(int x, int y) void AusgangstuerBlinken(int x, int y) { - DrawGraphicAnimation(x, y, GFX_AUSGANG_AUF, 4, 4, ANIM_PINGPONG); + DrawGraphicAnimation(x, y, IMG_EXIT_OPEN); } void OpenSwitchgate(int x, int y) @@ -4039,12 +4056,15 @@ void OpenSwitchgate(int x, int y) if (MovDelay[x][y]) /* wait some time before next frame */ { - int phase; - MovDelay[x][y]--; - phase = MovDelay[x][y] / delay; + if (!(MovDelay[x][y] % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - DrawGraphic(SCREENX(x), SCREENY(y), GFX_SWITCHGATE_OPEN - phase); + { + int frame = getGraphicAnimationFrame(IMG_SWITCHGATE_OPENING, + 29 - MovDelay[x][y]); + + DrawGraphic(SCREENX(x), SCREENY(y), IMG_SWITCHGATE_OPENING, frame); + } if (!MovDelay[x][y]) { @@ -4063,12 +4083,15 @@ void CloseSwitchgate(int x, int y) if (MovDelay[x][y]) /* wait some time before next frame */ { - int phase; - MovDelay[x][y]--; - phase = MovDelay[x][y] / delay; + if (!(MovDelay[x][y] % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - DrawGraphic(SCREENX(x), SCREENY(y), GFX_SWITCHGATE_CLOSED + phase); + { + int frame = getGraphicAnimationFrame(IMG_SWITCHGATE_CLOSING, + 29 - MovDelay[x][y]); + + DrawGraphic(SCREENX(x), SCREENY(y), IMG_SWITCHGATE_CLOSING, frame); + } if (!MovDelay[x][y]) { @@ -4087,12 +4110,15 @@ void OpenTimegate(int x, int y) if (MovDelay[x][y]) /* wait some time before next frame */ { - int phase; - MovDelay[x][y]--; - phase = MovDelay[x][y] / delay; + if (!(MovDelay[x][y] % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - DrawGraphic(SCREENX(x), SCREENY(y), GFX_TIMEGATE_OPEN - phase); + { + int frame = getGraphicAnimationFrame(IMG_TIMEGATE_OPENING, + 29 - MovDelay[x][y]); + + DrawGraphic(SCREENX(x), SCREENY(y), IMG_TIMEGATE_OPENING, frame); + } if (!MovDelay[x][y]) { @@ -4111,12 +4137,15 @@ void CloseTimegate(int x, int y) if (MovDelay[x][y]) /* wait some time before next frame */ { - int phase; - MovDelay[x][y]--; - phase = MovDelay[x][y] / delay; + if (!(MovDelay[x][y] % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - DrawGraphic(SCREENX(x), SCREENY(y), GFX_TIMEGATE_CLOSED + phase); + { + int frame = getGraphicAnimationFrame(IMG_TIMEGATE_CLOSING, + 29 - MovDelay[x][y]); + + DrawGraphic(SCREENX(x), SCREENY(y), IMG_TIMEGATE_CLOSING, frame); + } if (!MovDelay[x][y]) { @@ -4151,7 +4180,7 @@ void EdelsteinFunkeln(int x, int y) return; if (Feld[x][y] == EL_BD_DIAMOND) - DrawGraphicAnimation(x, y, GFX_EDELSTEIN_BD, 4, 4, ANIM_REVERSE); + DrawGraphicAnimation(x, y, IMG_BD_DIAMOND); else { if (!MovDelay[x][y]) /* next animation frame */ @@ -4164,23 +4193,21 @@ void EdelsteinFunkeln(int x, int y) if (setup.direct_draw && MovDelay[x][y]) SetDrawtoField(DRAW_BUFFERED); - DrawGraphic(SCREENX(x), SCREENY(y), el2gfx(Feld[x][y])); + DrawGraphic(SCREENX(x), SCREENY(y), el2img(Feld[x][y]), 0); if (MovDelay[x][y]) { - int phase = (MovDelay[x][y]-1)/2; - - if (phase > 2) - phase = 4-phase; + int frame = getGraphicAnimationFrame(IMG_TWINKLE_WHITE, + 10 - MovDelay[x][y]); - DrawGraphicThruMask(SCREENX(x), SCREENY(y), GFX_FUNKELN_WEISS + phase); + DrawGraphicThruMask(SCREENX(x), SCREENY(y), IMG_TWINKLE_WHITE, frame); if (setup.direct_draw) { int dest_x, dest_y; - dest_x = FX + SCREENX(x)*TILEX; - dest_y = FY + SCREENY(y)*TILEY; + dest_x = FX + SCREENX(x) * TILEX; + dest_y = FY + SCREENY(y) * TILEY; BlitBitmap(drawto_field, window, dest_x, dest_y, TILEX, TILEY, dest_x, dest_y); @@ -4196,42 +4223,41 @@ void MauerWaechst(int x, int y) int delay = 6; if (!MovDelay[x][y]) /* next animation frame */ - MovDelay[x][y] = 3*delay; + MovDelay[x][y] = 3 * delay; if (MovDelay[x][y]) /* wait some time before next frame */ { - int phase; - MovDelay[x][y]--; - phase = 2-MovDelay[x][y]/delay; - if (!(MovDelay[x][y]%delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - DrawGraphic(SCREENX(x), SCREENY(y), - (MovDir[x][y] == MV_LEFT ? GFX_MAUER_LEFT : - MovDir[x][y] == MV_RIGHT ? GFX_MAUER_RIGHT : - MovDir[x][y] == MV_UP ? GFX_MAUER_UP : - GFX_MAUER_DOWN ) + phase); + + if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + { + int graphic = el_dir2img(Feld[x][y], MovDir[x][y]); + int frame = getGraphicAnimationFrame(graphic, 17 - MovDelay[x][y]); + + DrawGraphic(SCREENX(x), SCREENY(y), graphic, frame); + } if (!MovDelay[x][y]) { if (MovDir[x][y] == MV_LEFT) { - if (IN_LEV_FIELD(x-1, y) && IS_MAUER(Feld[x-1][y])) - DrawLevelField(x-1, y); + if (IN_LEV_FIELD(x - 1, y) && IS_MAUER(Feld[x - 1][y])) + DrawLevelField(x - 1, y); } else if (MovDir[x][y] == MV_RIGHT) { - if (IN_LEV_FIELD(x+1, y) && IS_MAUER(Feld[x+1][y])) - DrawLevelField(x+1, y); + if (IN_LEV_FIELD(x + 1, y) && IS_MAUER(Feld[x + 1][y])) + DrawLevelField(x + 1, y); } else if (MovDir[x][y] == MV_UP) { - if (IN_LEV_FIELD(x, y-1) && IS_MAUER(Feld[x][y-1])) - DrawLevelField(x, y-1); + if (IN_LEV_FIELD(x, y - 1) && IS_MAUER(Feld[x][y - 1])) + DrawLevelField(x, y - 1); } else { - if (IN_LEV_FIELD(x, y+1) && IS_MAUER(Feld[x][y+1])) - DrawLevelField(x, y+1); + if (IN_LEV_FIELD(x, y + 1) && IS_MAUER(Feld[x][y + 1])) + DrawLevelField(x, y + 1); } Feld[x][y] = Store[x][y]; @@ -4278,7 +4304,8 @@ void MauerAbleger(int ax, int ay) Store[ax][ay-1] = element; MovDir[ax][ay-1] = MV_UP; if (IN_SCR_FIELD(SCREENX(ax), SCREENY(ay-1))) - DrawGraphic(SCREENX(ax), SCREENY(ay-1), GFX_MAUER_UP); + DrawGraphic(SCREENX(ax), SCREENY(ay - 1), + IMG_WALL_GROWING_ACTIVE_UP, 0); new_wall = TRUE; } if (unten_frei) @@ -4287,7 +4314,8 @@ void MauerAbleger(int ax, int ay) Store[ax][ay+1] = element; MovDir[ax][ay+1] = MV_DOWN; if (IN_SCR_FIELD(SCREENX(ax), SCREENY(ay+1))) - DrawGraphic(SCREENX(ax), SCREENY(ay+1), GFX_MAUER_DOWN); + DrawGraphic(SCREENX(ax), SCREENY(ay + 1), + IMG_WALL_GROWING_ACTIVE_DOWN, 0); new_wall = TRUE; } } @@ -4301,7 +4329,8 @@ void MauerAbleger(int ax, int ay) Store[ax-1][ay] = element; MovDir[ax-1][ay] = MV_LEFT; if (IN_SCR_FIELD(SCREENX(ax-1), SCREENY(ay))) - DrawGraphic(SCREENX(ax-1), SCREENY(ay), GFX_MAUER_LEFT); + DrawGraphic(SCREENX(ax - 1), SCREENY(ay), + IMG_WALL_GROWING_ACTIVE_LEFT, 0); new_wall = TRUE; } @@ -4311,7 +4340,8 @@ void MauerAbleger(int ax, int ay) Store[ax+1][ay] = element; MovDir[ax+1][ay] = MV_RIGHT; if (IN_SCR_FIELD(SCREENX(ax+1), SCREENY(ay))) - DrawGraphic(SCREENX(ax+1), SCREENY(ay), GFX_MAUER_RIGHT); + DrawGraphic(SCREENX(ax + 1), SCREENY(ay), + IMG_WALL_GROWING_ACTIVE_RIGHT, 0); new_wall = TRUE; } } @@ -4400,7 +4430,7 @@ static void CheckBuggyBase(int x, int y) { MovDelay[x][y]--; if (MovDelay[x][y] < 5 && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - DrawGraphic(SCREENX(x), SCREENY(y), GFX_SP_BUG_WARNING); + DrawGraphic(SCREENX(x), SCREENY(y), IMG_SP_BUGGY_BASE, 0); if (MovDelay[x][y]) return; @@ -4427,7 +4457,12 @@ static void CheckBuggyBase(int x, int y) }; if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - DrawGraphic(SCREENX(x),SCREENY(y), GFX_SP_BUG_ACTIVE + SimpleRND(4)); + { + int graphic = IMG_SP_BUGGY_BASE_ACTIVE; + int frame = getGraphicAnimationFrame(graphic, SimpleRND(100)); + + DrawGraphic(SCREENX(x), SCREENY(y), graphic, frame); + } for (i=0; i<4; i++) { @@ -4484,15 +4519,13 @@ static void CheckTrap(int x, int y) { if (!(MovDelay[x][y] % delay)) { - int phase = MovDelay[x][y]/delay; - - if (phase >= num_frames/2) - phase = num_frames - phase; - if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) { - DrawGraphic(SCREENX(x),SCREENY(y), GFX_TRAP_INACTIVE + phase - 1); - ErdreichAnbroeckeln(SCREENX(x), SCREENY(y)); + int graphic = IMG_TRAP_ACTIVE; + int frame = getGraphicAnimationFrame(graphic, 31 - MovDelay[x][y]); + + DrawGraphic(SCREENX(x),SCREENY(y), graphic, frame); + DrawCrumbledSand(SCREENX(x), SCREENY(y)); } } @@ -4512,11 +4545,9 @@ static void DrawBeltAnimation(int x, int y, int element) if (belt_dir != MV_NO_MOVING) { - int delay = 2; - int mode = (belt_dir == MV_LEFT ? ANIM_NORMAL : ANIM_REVERSE); - int graphic = el2gfx(element) + (belt_dir == MV_LEFT ? 0 : 7); + int graphic = el2img(element); - DrawGraphicAnimation(x, y, graphic, 8, delay, mode); + DrawGraphicAnimation(x, y, graphic); if (!(FrameCounter % 2)) PlaySoundLevel(x, y, SND_CONVEYOR_BELT_ACTIVE); @@ -4613,6 +4644,7 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) */ #endif + /* if the player does not move for some time, reset animation to start */ if (++player->frame_reset_delay > player->move_delay_value) player->Frame = 0; } @@ -4840,10 +4872,10 @@ void GameActions() TimegateWheel(x, y); else if (element == EL_ACID) Blubber(x, y); - else if (element == EL_ACID_SPLASHING_LEFT || - element == EL_ACID_SPLASHING_RIGHT) + else if (element == EL_ACID_SPLASH_LEFT || + element == EL_ACID_SPLASH_RIGHT) Blurb(x, y); - else if (element == EL_CRACKINGNUT) + else if (element == EL_NUT_CRACKING) NussKnacken(x, y); else if (element == EL_PEARL_BREAKING) BreakingPearl(x, y); @@ -4871,10 +4903,11 @@ void GameActions() else if (element == EL_TRAP || element == EL_TRAP_ACTIVE) CheckTrap(x, y); else if (element == EL_SP_TERMINAL) - DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL, 7, 12, ANIM_NORMAL); + DrawGraphicAnimation(x, y, IMG_SP_TERMINAL); else if (element == EL_SP_TERMINAL_ACTIVE) { - DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL_ACTIVE, 7, 4, ANIM_NORMAL); + DrawGraphicAnimation(x, y, IMG_SP_TERMINAL_ACTIVE); + #if 0 if (!(FrameCounter % 4)) PlaySoundLevel(x, y, SND_SP_TERMINAL_ACTIVE); @@ -4891,10 +4924,11 @@ void GameActions() else if (element == EL_TIMEGATE_CLOSING) CloseTimegate(x, y); else if (element == EL_EXTRA_TIME) - DrawGraphicAnimation(x, y, GFX_EXTRA_TIME, 6, 4, ANIM_NORMAL); + DrawGraphicAnimation(x, y, IMG_EXTRA_TIME); else if (element == EL_SHIELD_NORMAL) { - DrawGraphicAnimation(x, y, GFX_SHIELD_PASSIVE, 6, 4, ANIM_NORMAL); + DrawGraphicAnimation(x, y, IMG_SHIELD_NORMAL); + #if 0 if (!(FrameCounter % 4)) PlaySoundLevel(x, y, SND_SHIELD_PASSIVE_ACTIVATED); @@ -4902,7 +4936,8 @@ void GameActions() } else if (element == EL_SHIELD_DEADLY) { - DrawGraphicAnimation(x, y, GFX_SHIELD_ACTIVE, 6, 4, ANIM_NORMAL); + DrawGraphicAnimation(x, y, IMG_SHIELD_DEADLY); + #if 0 if (!(FrameCounter % 4)) PlaySoundLevel(x, y, SND_SHIELD_DEADLY_ACTIVE); @@ -4961,8 +4996,8 @@ void GameActions() (element == EL_EMPTY || element == EL_SAND || element == EL_QUICKSAND_EMPTY || - element == EL_ACID_SPLASHING_LEFT || - element == EL_ACID_SPLASHING_RIGHT)) + element == EL_ACID_SPLASH_LEFT || + element == EL_ACID_SPLASH_RIGHT)) { if ((IN_LEV_FIELD(x, y-1) && Feld[x][y-1] == EL_AMOEBA_WET) || (IN_LEV_FIELD(x-1, y) && Feld[x-1][y] == EL_AMOEBA_WET) || @@ -5061,9 +5096,9 @@ void GameActions() if (SHIELD_ON(player)) { - if (player->shield_active_time_left) + if (player->shield_deadly_time_left) PlaySoundLevel(player->jx, player->jy, SND_SHIELD_DEADLY_ACTIVE); - else if (player->shield_passive_time_left) + else if (player->shield_normal_time_left) PlaySoundLevel(player->jx, player->jy, SND_SHIELD_NORMAL_ACTIVE); } } @@ -5079,10 +5114,10 @@ void GameActions() if (SHIELD_ON(player)) { - player->shield_passive_time_left--; + player->shield_normal_time_left--; - if (player->shield_active_time_left > 0) - player->shield_active_time_left--; + if (player->shield_deadly_time_left > 0) + player->shield_deadly_time_left--; } } @@ -5186,6 +5221,7 @@ void ScrollLevel(int dx, int dy) for (y=BY1; y<=BY2; y++) DrawScreenField(x, y); } + if (dy) { y = (dy == 1 ? BY1 : BY2); @@ -5422,7 +5458,11 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy) if (!(moved & MF_MOVING) && !player->Pushing) player->Frame = 0; else +#if 0 player->Frame = (player->Frame + 1) % 4; +#else + player->Frame += 1 * 0; +#endif if (moved & MF_MOVING) { @@ -5431,7 +5471,7 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy) else if (old_jx == jx && old_jy != jy) player->MovDir = (old_jy < jy ? MV_DOWN : MV_UP); - DrawLevelField(jx, jy); /* for "ErdreichAnbroeckeln()" */ + DrawLevelField(jx, jy); /* for "DrawCrumbledSand()" */ player->last_move_dir = player->MovDir; player->is_moving = TRUE; @@ -5467,6 +5507,8 @@ void ScrollFigure(struct PlayerInfo *player, int mode) { player->actual_frame_counter = FrameCounter; player->GfxPos = move_stepsize * (player->MovPos / move_stepsize); + if (player->Frame) + player->Frame += 1; if (Feld[last_jx][last_jy] == EL_EMPTY) Feld[last_jx][last_jy] = EL_PLAYER_IS_LEAVING; @@ -5479,6 +5521,7 @@ void ScrollFigure(struct PlayerInfo *player, int mode) player->MovPos += (player->MovPos > 0 ? -1 : 1) * move_stepsize; player->GfxPos = move_stepsize * (player->MovPos / move_stepsize); + player->Frame += 1; if (Feld[last_jx][last_jy] == EL_PLAYER_IS_LEAVING) Feld[last_jx][last_jy] = EL_EMPTY; @@ -5601,7 +5644,7 @@ void TestIfGoodThingHitsBadThing(int good_x, int good_y, int good_move_dir) { struct PlayerInfo *player = PLAYERINFO(good_x, good_y); - if (player->shield_active_time_left > 0) + if (player->shield_deadly_time_left > 0) Bang(kill_x, kill_y); else if (!PLAYER_PROTECTED(good_x, good_y)) KillHero(player); @@ -5698,7 +5741,7 @@ void TestIfBadThingHitsGoodThing(int bad_x, int bad_y, int bad_move_dir) ; #endif - if (player->shield_active_time_left > 0) + if (player->shield_deadly_time_left > 0) Bang(bad_x, bad_y); else if (!PLAYER_PROTECTED(kill_x, kill_y)) KillHero(player); @@ -5783,8 +5826,8 @@ void KillHero(struct PlayerInfo *player) Feld[jx][jy] = EL_EMPTY; /* deactivate shield (else Bang()/Explode() would not work right) */ - player->shield_passive_time_left = 0; - player->shield_active_time_left = 0; + player->shield_normal_time_left = 0; + player->shield_deadly_time_left = 0; Bang(jx, jy); BuryHero(player); @@ -5946,14 +5989,14 @@ int DigField(struct PlayerInfo *player, case EL_SHIELD_NORMAL: RemoveField(x, y); - player->shield_passive_time_left += 10; + player->shield_normal_time_left += 10; PlaySoundLevel(x, y, SND_SHIELD_NORMAL_COLLECTING); break; case EL_SHIELD_DEADLY: RemoveField(x, y); - player->shield_passive_time_left += 10; - player->shield_active_time_left += 10; + player->shield_normal_time_left += 10; + player->shield_deadly_time_left += 10; PlaySoundLevel(x, y, SND_SHIELD_DEADLY_COLLECTING); break; @@ -6186,7 +6229,7 @@ int DigField(struct PlayerInfo *player, player->push_delay_value = (element == EL_SPRING ? 0 : 2 + RND(8)); - DrawLevelField(x+dx, y+dy); + DrawLevelField(x + dx, y + dy); PlaySoundLevelElementAction(x, y, element, SND_ACTION_PUSHING); break; @@ -6451,7 +6494,7 @@ int DigField(struct PlayerInfo *player, player->push_delay_value = (element == EL_BALLOON ? 0 : 2); DrawLevelField(x, y); - DrawLevelField(x+dx, y+dy); + DrawLevelField(x + dx, y + dy); if (IS_SB_ELEMENT(element) && local_player->sokobanfields_still_needed == 0 && @@ -6542,9 +6585,9 @@ boolean PlaceBomb(struct PlayerInfo *player) if (IN_SCR_FIELD(SCREENX(jx), SCREENY(jy))) { if (game.emulation == EMU_SUPAPLEX) - DrawGraphic(SCREENX(jx), SCREENY(jy), GFX_SP_DISK_RED); + DrawGraphic(SCREENX(jx), SCREENY(jy), IMG_SP_DISK_RED, 0); else - DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), GFX_DYNAMIT); + DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), IMG_DYNAMITE_ACTIVE, 0); } PlaySoundLevel(jx, jy, SND_DYNAMITE_DROPPING); @@ -6556,7 +6599,7 @@ boolean PlaceBomb(struct PlayerInfo *player) MovDelay[jx][jy] = 96; player->dynabombs_left--; if (IN_SCR_FIELD(SCREENX(jx), SCREENY(jy))) - DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), GFX_DYNABOMB); + DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), el2img(Feld[jx][jy]), 0); PlaySoundLevel(jx, jy, SND_DYNABOMB_DROPPING); }