X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=8b812e538fcb95a460d85f3acfd610026ccd5cdc;hb=9d7b311c097571c6eb4a810029400dbbc9267a90;hp=32ee2ac3ef708231db380c2366b3e21577bb72c4;hpb=08ad905f20de863e1f86eb772ecc2fbf7721529d;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index 32ee2ac3..8b812e53 100644 --- a/src/game.c +++ b/src/game.c @@ -1706,15 +1706,13 @@ void Explode(int ex, int ey, int phase, int mode) if (IS_PLAYER(x, y) && !PLAYERINFO(x,y)->present) StorePlayer[x][y] = 0; } - else if (!(phase % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + else if (phase >= delay && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) { - int graphic = IMG_EXPLOSION; - int frame = (phase / delay - 1); - - if (game.emulation == EMU_SUPAPLEX) - graphic = (Store[x][y] == EL_SP_INFOTRON ? - IMG_SP_EXPLOSION_INFOTRON : - IMG_SP_EXPLOSION); + int stored = Store[x][y]; + int graphic = (game.emulation != EMU_SUPAPLEX ? IMG_EXPLOSION : + stored == EL_SP_INFOTRON ? IMG_SP_EXPLOSION_INFOTRON : + IMG_SP_EXPLOSION); + int frame = getGraphicAnimationFrame(graphic, phase - delay); if (phase == delay) DrawCrumbledSand(SCREENX(x), SCREENY(y)); @@ -2986,7 +2984,7 @@ void StartMoving(int x, int y) } } else if (element == EL_SP_ELECTRON) - DrawGraphicAnimation(x, y, IMG_SP_ELECTRON); + DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_SP_ELECTRON); else if (element == EL_DRAGON) { int i; @@ -3244,11 +3242,11 @@ void StartMoving(int x, int y) element == EL_SP_SNIKSNAK || element == EL_MOLE) DrawLevelField(x, y); else if (element == EL_BD_BUTTERFLY || element == EL_BD_FIREFLY) - DrawGraphicAnimation(x, y, el2img(element)); + DrawGraphicAnimation(SCREENX(x), SCREENY(y), el2img(element)); else if (element == EL_SATELLITE) - DrawGraphicAnimation(x, y, IMG_SATELLITE); + DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_SATELLITE); else if (element == EL_SP_ELECTRON) - DrawGraphicAnimation(x, y, IMG_SP_ELECTRON); + DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_SP_ELECTRON); if (DONT_TOUCH(element)) TestIfBadThingTouchesHero(x, y); @@ -3390,8 +3388,14 @@ void ContinueMoving(int x, int y) if (!CAN_MOVE(element)) MovDir[newx][newy] = 0; #else + /* if (CAN_FALL(element) && MovDir[newx][newy] == MV_DOWN) MovDir[newx][newy] = 0; + */ + + if (!CAN_MOVE(element) || + (element == EL_SPRING && MovDir[newx][newy] == MV_DOWN)) + MovDir[newx][newy] = 0; #endif DrawLevelField(x, y); @@ -3917,14 +3921,15 @@ void RobotWheel(int x, int y) DrawGraphic(SCREENX(x), SCREENY(y), IMG_ROBOT_WHEEL_ACTIVE, frame); } - if (!(MovDelay[x][y]%4)) - PlaySoundLevel(x, y, SND_ROBOT_WHEEL_ACTIVE); + PlaySoundLevel(x, y, SND_ROBOT_WHEEL_ACTIVE); + return; } } Feld[x][y] = EL_ROBOT_WHEEL; DrawLevelField(x, y); + if (ZX == x && ZY == y) ZX = ZY = -1; } @@ -3946,23 +3951,20 @@ void TimegateWheel(int x, int y) DrawGraphic(SCREENX(x), SCREENY(y), IMG_TIMEGATE_SWITCH_ACTIVE, frame); } - if (!(MovDelay[x][y]%4)) - PlaySoundLevel(x, y, SND_TIMEGATE_SWITCH_ACTIVE); + PlaySoundLevel(x, y, SND_TIMEGATE_SWITCH_ACTIVE); + return; } } Feld[x][y] = EL_TIMEGATE_SWITCH; DrawLevelField(x, y); + + /* !!! THIS LOOKS WRONG !!! */ if (ZX == x && ZY == y) ZX = ZY = -1; } -void Blubber(int x, int y) -{ - DrawGraphicAnimation(x, y, IMG_ACID); -} - void NussKnacken(int x, int y) { if (!MovDelay[x][y]) /* next animation frame */ @@ -3971,20 +3973,22 @@ void NussKnacken(int x, int y) if (MovDelay[x][y]) /* wait some time before next frame */ { MovDelay[x][y]--; - if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + if (MovDelay[x][y]) { - int frame = getGraphicAnimationFrame(IMG_NUT_CRACKING, - 6 - MovDelay[x][y]); + if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + { + int frame = getGraphicAnimationFrame(IMG_NUT_CRACKING, + 6 - MovDelay[x][y]); - DrawGraphic(SCREENX(x), SCREENY(y), IMG_NUT_CRACKING, frame); - } + DrawGraphic(SCREENX(x), SCREENY(y), IMG_NUT_CRACKING, frame); + } - if (!MovDelay[x][y]) - { - Feld[x][y] = EL_EMERALD; - DrawLevelField(x, y); + return; } } + + Feld[x][y] = EL_EMERALD; + DrawLevelField(x, y); } void BreakingPearl(int x, int y) @@ -3995,27 +3999,29 @@ void BreakingPearl(int x, int y) if (MovDelay[x][y]) /* wait some time before next frame */ { MovDelay[x][y]--; - if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + if (MovDelay[x][y]) { - int frame = getGraphicAnimationFrame(IMG_PEARL_BREAKING, - 8 - MovDelay[x][y]); + if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + { + int frame = getGraphicAnimationFrame(IMG_PEARL_BREAKING, + 8 - MovDelay[x][y]); - DrawGraphic(SCREENX(x), SCREENY(y), IMG_PEARL_BREAKING, frame); - } + DrawGraphic(SCREENX(x), SCREENY(y), IMG_PEARL_BREAKING, frame); + } - if (!MovDelay[x][y]) - { - Feld[x][y] = EL_EMPTY; - DrawLevelField(x, y); + return; } } + + Feld[x][y] = EL_EMPTY; + DrawLevelField(x, y); } void SiebAktivieren(int x, int y, int type) { int graphic = (type == 1 ? IMG_MAGIC_WALL_FULL : IMG_BD_MAGIC_WALL_FULL); - DrawGraphicAnimation(x, y, graphic); + DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic); } void AusgangstuerPruefen(int x, int y) @@ -4060,26 +4066,24 @@ void AusgangstuerOeffnen(int x, int y) int tuer; MovDelay[x][y]--; - tuer = MovDelay[x][y]/delay; - if (!(MovDelay[x][y]%delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + tuer = MovDelay[x][y] / delay; + + if (!(MovDelay[x][y] % delay)) { - int frame = getGraphicAnimationFrame(IMG_EXIT_OPENING, - 29 - MovDelay[x][y]); + if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + { + int frame = getGraphicAnimationFrame(IMG_EXIT_OPENING, + 29 - MovDelay[x][y]); - DrawGraphic(SCREENX(x), SCREENY(y), IMG_EXIT_OPENING, frame); - } + DrawGraphic(SCREENX(x), SCREENY(y), IMG_EXIT_OPENING, frame); + } - if (!MovDelay[x][y]) - { - Feld[x][y] = EL_EXIT_OPEN; - DrawLevelField(x, y); + return; } } -} -void AusgangstuerBlinken(int x, int y) -{ - DrawGraphicAnimation(x, y, IMG_EXIT_OPEN); + Feld[x][y] = EL_EXIT_OPEN; + DrawLevelField(x, y); } void OpenSwitchgate(int x, int y) @@ -4093,20 +4097,22 @@ void OpenSwitchgate(int x, int y) { MovDelay[x][y]--; - if (!(MovDelay[x][y] % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + if (!(MovDelay[x][y] % delay)) { - int frame = getGraphicAnimationFrame(IMG_SWITCHGATE_OPENING, - 29 - MovDelay[x][y]); + if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + { + int frame = getGraphicAnimationFrame(IMG_SWITCHGATE_OPENING, + 29 - MovDelay[x][y]); - DrawGraphic(SCREENX(x), SCREENY(y), IMG_SWITCHGATE_OPENING, frame); - } + DrawGraphic(SCREENX(x), SCREENY(y), IMG_SWITCHGATE_OPENING, frame); + } - if (!MovDelay[x][y]) - { - Feld[x][y] = EL_SWITCHGATE_OPEN; - DrawLevelField(x, y); + return; } } + + Feld[x][y] = EL_SWITCHGATE_OPEN; + DrawLevelField(x, y); } void CloseSwitchgate(int x, int y) @@ -4120,20 +4126,22 @@ void CloseSwitchgate(int x, int y) { MovDelay[x][y]--; - if (!(MovDelay[x][y] % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + if (!(MovDelay[x][y] % delay)) { - int frame = getGraphicAnimationFrame(IMG_SWITCHGATE_CLOSING, - 29 - MovDelay[x][y]); + if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + { + int frame = getGraphicAnimationFrame(IMG_SWITCHGATE_CLOSING, + 29 - MovDelay[x][y]); - DrawGraphic(SCREENX(x), SCREENY(y), IMG_SWITCHGATE_CLOSING, frame); - } + DrawGraphic(SCREENX(x), SCREENY(y), IMG_SWITCHGATE_CLOSING, frame); + } - if (!MovDelay[x][y]) - { - Feld[x][y] = EL_SWITCHGATE_CLOSED; - DrawLevelField(x, y); + return; } } + + Feld[x][y] = EL_SWITCHGATE_CLOSED; + DrawLevelField(x, y); } void OpenTimegate(int x, int y) @@ -4147,20 +4155,22 @@ void OpenTimegate(int x, int y) { MovDelay[x][y]--; - if (!(MovDelay[x][y] % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + if (!(MovDelay[x][y] % delay)) { - int frame = getGraphicAnimationFrame(IMG_TIMEGATE_OPENING, - 29 - MovDelay[x][y]); + if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + { + int frame = getGraphicAnimationFrame(IMG_TIMEGATE_OPENING, + 29 - MovDelay[x][y]); - DrawGraphic(SCREENX(x), SCREENY(y), IMG_TIMEGATE_OPENING, frame); - } + DrawGraphic(SCREENX(x), SCREENY(y), IMG_TIMEGATE_OPENING, frame); + } - if (!MovDelay[x][y]) - { - Feld[x][y] = EL_TIMEGATE_OPEN; - DrawLevelField(x, y); + return; } } + + Feld[x][y] = EL_TIMEGATE_OPEN; + DrawLevelField(x, y); } void CloseTimegate(int x, int y) @@ -4174,20 +4184,22 @@ void CloseTimegate(int x, int y) { MovDelay[x][y]--; - if (!(MovDelay[x][y] % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + if (!(MovDelay[x][y] % delay)) { - int frame = getGraphicAnimationFrame(IMG_TIMEGATE_CLOSING, - 29 - MovDelay[x][y]); + if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) + { + int frame = getGraphicAnimationFrame(IMG_TIMEGATE_CLOSING, + 29 - MovDelay[x][y]); - DrawGraphic(SCREENX(x), SCREENY(y), IMG_TIMEGATE_CLOSING, frame); - } + DrawGraphic(SCREENX(x), SCREENY(y), IMG_TIMEGATE_CLOSING, frame); + } - if (!MovDelay[x][y]) - { - Feld[x][y] = EL_TIMEGATE_CLOSED; - DrawLevelField(x, y); + return; } } + + Feld[x][y] = EL_TIMEGATE_CLOSED; + DrawLevelField(x, y); } static void CloseAllOpenTimegates() @@ -4215,7 +4227,7 @@ void EdelsteinFunkeln(int x, int y) return; if (Feld[x][y] == EL_BD_DIAMOND) - DrawGraphicAnimation(x, y, IMG_BD_DIAMOND); + DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_BD_DIAMOND); else { if (!MovDelay[x][y]) /* next animation frame */ @@ -4228,7 +4240,11 @@ void EdelsteinFunkeln(int x, int y) if (setup.direct_draw && MovDelay[x][y]) SetDrawtoField(DRAW_BUFFERED); +#if 0 DrawGraphic(SCREENX(x), SCREENY(y), el2img(Feld[x][y]), 0); +#else + DrawGraphicAnimation(SCREENX(x), SCREENY(y), el2img(Feld[x][y])); +#endif if (MovDelay[x][y]) { @@ -4582,7 +4598,7 @@ static void DrawBeltAnimation(int x, int y, int element) { int graphic = el2img(element); - DrawGraphicAnimation(x, y, graphic); + DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic); if (!(FrameCounter % 2)) PlaySoundLevel(x, y, SND_CONVEYOR_BELT_ACTIVE); @@ -4878,6 +4894,13 @@ void GameActions() { StartMoving(x, y); +#if 1 + if (Feld[x][y] == EL_EMERALD && + new_graphic_info[IMG_EMERALD].anim_frames > 1 && + !IS_MOVING(x, y)) + DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_EMERALD); +#endif + if (IS_GEM(element) || element == EL_SP_INFOTRON) EdelsteinFunkeln(x, y); } @@ -4906,7 +4929,7 @@ void GameActions() else if (element == EL_TIMEGATE_SWITCH_ACTIVE) TimegateWheel(x, y); else if (element == EL_ACID) - Blubber(x, y); + DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_ACID); else if (element == EL_ACID_SPLASH_LEFT || element == EL_ACID_SPLASH_RIGHT) Blurb(x, y); @@ -4921,9 +4944,9 @@ void GameActions() else if (element == EL_EXIT_OPENING) AusgangstuerOeffnen(x, y); else if (element == EL_EXIT_OPEN) - AusgangstuerBlinken(x, y); + DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_EXIT_OPEN); else if (element == EL_SP_EXIT_OPEN) - ; /* !!! ADD SOME (OPTIONAL) ANIMATIONS HERE !!! */ + DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_SP_EXIT_OPEN); else if (element == EL_WALL_GROWING_ACTIVE) MauerWaechst(x, y); else if (element == EL_WALL_GROWING || @@ -4938,16 +4961,9 @@ void GameActions() else if (element == EL_TRAP || element == EL_TRAP_ACTIVE) CheckTrap(x, y); else if (element == EL_SP_TERMINAL) - DrawGraphicAnimation(x, y, IMG_SP_TERMINAL); + DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_SP_TERMINAL); else if (element == EL_SP_TERMINAL_ACTIVE) - { - DrawGraphicAnimation(x, y, IMG_SP_TERMINAL_ACTIVE); - -#if 0 - if (!(FrameCounter % 4)) - PlaySoundLevel(x, y, SND_SP_TERMINAL_ACTIVE); -#endif - } + DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_SP_TERMINAL_ACTIVE); else if (IS_BELT_ACTIVE(element)) DrawBeltAnimation(x, y, element); else if (element == EL_SWITCHGATE_OPENING) @@ -4959,25 +4975,11 @@ void GameActions() else if (element == EL_TIMEGATE_CLOSING) CloseTimegate(x, y); else if (element == EL_EXTRA_TIME) - DrawGraphicAnimation(x, y, IMG_EXTRA_TIME); + DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_EXTRA_TIME); else if (element == EL_SHIELD_NORMAL) - { - DrawGraphicAnimation(x, y, IMG_SHIELD_NORMAL); - -#if 0 - if (!(FrameCounter % 4)) - PlaySoundLevel(x, y, SND_SHIELD_PASSIVE_ACTIVATED); -#endif - } + DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_SHIELD_NORMAL); else if (element == EL_SHIELD_DEADLY) - { - DrawGraphicAnimation(x, y, IMG_SHIELD_DEADLY); - -#if 0 - if (!(FrameCounter % 4)) - PlaySoundLevel(x, y, SND_SHIELD_DEADLY_ACTIVE); -#endif - } + DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_SHIELD_DEADLY); if (game.magic_wall_active) {