X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=aad2757881fabbc437990a08c68ab047d40e9bcb;hb=1c3065c351ef8a8637af5540dea2b39c1d86e80f;hp=4b726a43f39fc7a5221077ba13f39c9c0fb819a5;hpb=6435b79b71c4033de78ab3e611ee63f6a2147874;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index 4b726a43..aad27578 100644 --- a/src/game.c +++ b/src/game.c @@ -533,21 +533,15 @@ static void InitGameEngine() }; static int ep_em_slippery_wall_num = SIZEOF_ARRAY_INT(ep_em_slippery_wall); + /* special EM style gems behaviour */ for (i=0; i VERSION_IDENT(2,0,1)) - Properties2[EL_EXPANDABLE_WALL_GROWING] |= EP_BIT_EM_SLIPPERY_WALL; - else - Properties2[EL_EXPANDABLE_WALL_GROWING] &=~EP_BIT_EM_SLIPPERY_WALL; + SET_PROPERTY(EL_EXPANDABLE_WALL_GROWING, EP_EM_SLIPPERY_WALL, + (level.em_slippery_gems && + game.engine_version > VERSION_IDENT(2,0,1))); } /* initialize changing elements information */ @@ -729,7 +723,7 @@ void InitGame() { Feld[x][y] = Ur[x][y]; MovPos[x][y] = MovDir[x][y] = MovDelay[x][y] = 0; - Store[x][y] = Store2[x][y] = StorePlayer[x][y] = 0; + Store[x][y] = Store2[x][y] = StorePlayer[x][y] = Back[x][y] = 0; AmoebaNr[x][y] = 0; JustStopped[x][y] = 0; Stop[x][y] = FALSE; @@ -919,7 +913,7 @@ void InitGame() else { DrawTextExt(drawto, DX + XX_EMERALDS, DY + YY_EMERALDS, - int2str(level_nr, 3), FONT_LEVEL_NUMBER, FONT_OPAQUE); + int2str(level_nr, 3), FONT_LEVEL_NUMBER, BLIT_OPAQUE); BlitBitmap(drawto, drawto, DX + XX_EMERALDS, DY + YY_EMERALDS + 1, getFontWidth(FONT_LEVEL_NUMBER) * 3, @@ -1112,7 +1106,7 @@ void GameWon() if (!tape.playing && !setup.sound_loops) PlaySoundStereo(SND_GAME_LEVELTIME_BONUS, SOUND_MIDDLE); if (TimeLeft > 0 && !(TimeLeft % 10)) - RaiseScore(level.score[SC_ZEITBONUS]); + RaiseScore(level.score[SC_TIME_BONUS]); if (TimeLeft > 100 && !(TimeLeft % 10)) TimeLeft -= 10; else @@ -1138,7 +1132,7 @@ void GameWon() if (!tape.playing && !setup.sound_loops) PlaySoundStereo(SND_GAME_LEVELTIME_BONUS, SOUND_MIDDLE); if (TimePlayed < 999 && !(TimePlayed % 10)) - RaiseScore(level.score[SC_ZEITBONUS]); + RaiseScore(level.score[SC_TIME_BONUS]); if (TimePlayed < 900 && !(TimePlayed % 10)) TimePlayed += 10; else @@ -1384,6 +1378,7 @@ static int MovingOrBlocked2ElementIfNotLeaving(int x, int y) static void RemoveField(int x, int y) { Feld[x][y] = EL_EMPTY; + GfxElement[x][y] = EL_UNDEFINED; MovPos[x][y] = 0; MovDir[x][y] = 0; MovDelay[x][y] = 0; @@ -1438,13 +1433,18 @@ void DrawDynamite(int x, int y) if (!IN_SCR_FIELD(sx, sy) || IS_PLAYER(x, y)) return; - if (Store[x][y]) + if (IS_WALKABLE_INSIDE(Back[x][y])) + return; + + if (Back[x][y]) + DrawGraphic(sx, sy, el2img(Back[x][y]), 0); + else if (Store[x][y]) DrawGraphic(sx, sy, el2img(Store[x][y]), 0); frame = getGraphicAnimationFrame(graphic, GfxFrame[x][y]); #if 1 - if (Store[x][y]) + if (Back[x][y] || Store[x][y]) DrawGraphicThruMask(sx, sy, graphic, frame); else DrawGraphic(sx, sy, graphic, frame); @@ -1505,6 +1505,10 @@ void Explode(int ex, int ey, int phase, int mode) { int center_element = Feld[ex][ey]; + /* remove things displayed in background while burnig dynamite */ + if (!IS_INDESTRUCTIBLE(Back[x][y])) + Back[x][y] = 0; + if (IS_MOVING(ex, ey) || IS_BLOCKED(ex, ey)) { /* put moving element to center field (and let it explode there) */ @@ -1530,8 +1534,16 @@ void Explode(int ex, int ey, int phase, int mode) RemoveMovingField(x, y); } - if (IS_INDESTRUCTIBLE(element) || element == EL_FLAMES) +#if 1 + if ((IS_INDESTRUCTIBLE(element) && + (game.engine_version < VERSION_IDENT(2,2,0) || + (!IS_WALKABLE_OVER(element) && !IS_WALKABLE_UNDER(element)))) || + element == EL_FLAMES) continue; +#else + if (IS_INDESTRUCTIBLE(element) || element == EL_FLAMES) + continue; +#endif if (IS_PLAYER(x, y) && SHIELD_ON(PLAYERINFO(x, y))) { @@ -1545,9 +1557,26 @@ void Explode(int ex, int ey, int phase, int mode) continue; } +#if 1 + /* save walkable background elements while explosion on same tile */ + if (IS_INDESTRUCTIBLE(element)) + Back[x][y] = element; +#endif + + /* ignite explodable elements reached by other explosion */ if (element == EL_EXPLOSION) element = Store2[x][y]; +#if 0 + else if (IS_INDESTRUCTIBLE(Store2[x][y])) /* hard element under bomb */ + element = Store2[x][y]; +#endif + +#if 0 + else if (IS_INDESTRUCTIBLE(Store[x][y])) /* hard element under bomb */ + element = Store[x][y]; +#endif + if (IS_PLAYER(ex, ey) && !PLAYER_PROTECTED(ex, ey)) { switch(StorePlayer[ex][ey]) @@ -1570,6 +1599,18 @@ void Explode(int ex, int ey, int phase, int mode) if (game.emulation == EMU_SUPAPLEX) Store[x][y] = EL_EMPTY; } +#if 0 + else if (IS_INDESTRUCTIBLE(Store[x][y])) + ; +#endif +#if 0 + else if (IS_INDESTRUCTIBLE(element)) + Store[x][y] = element; +#endif +#if 0 + else if (IS_INDESTRUCTIBLE(element) && IS_ACCESSIBLE(element)) + Store[x][y] = element; +#endif else if (center_element == EL_MOLE) Store[x][y] = EL_EMERALD_RED; else if (center_element == EL_PENGUIN) @@ -1600,8 +1641,31 @@ void Explode(int ex, int ey, int phase, int mode) Store[x][y] = EL_PEARL; else if (element == EL_WALL_CRYSTAL) Store[x][y] = EL_CRYSTAL; +#if 1 +#if 0 +#if 0 + else if (IS_INDESTRUCTIBLE(element) && IS_ACCESSIBLE(element)) + Store[x][y] = element; +#else + else if (IS_INDESTRUCTIBLE(element)) + Store[x][y] = element; +#endif +#endif + else + Store[x][y] = EL_EMPTY; +#else + +#if 0 + else if (IS_PFORTE(element)) + Store[x][y] = element; + else + Store[x][y] = EL_EMPTY; +#else else if (!IS_PFORTE(Store[x][y])) Store[x][y] = EL_EMPTY; +#endif + +#endif if (x != ex || y != ey || center_element == EL_AMOEBA_TO_DIAMOND || mode == EX_BORDER) @@ -1617,6 +1681,7 @@ void Explode(int ex, int ey, int phase, int mode) } Feld[x][y] = EL_EXPLOSION; + GfxElement[x][y] = EL_UNDEFINED; MovDir[x][y] = MovPos[x][y] = 0; AmoebaNr[x][y] = 0; ExplodePhase[x][y] = 1; @@ -1670,6 +1735,13 @@ void Explode(int ex, int ey, int phase, int mode) element = Feld[x][y] = Store[x][y]; Store[x][y] = Store2[x][y] = 0; + +#if 1 + if (Back[x][y] && IS_INDESTRUCTIBLE(Back[x][y])) + element = Feld[x][y] = Back[x][y]; + Back[x][y] = 0; +#endif + MovDir[x][y] = MovPos[x][y] = MovDelay[x][y] = 0; InitField(x, y, FALSE); if (CAN_MOVE(element) || COULD_MOVE(element)) @@ -1688,8 +1760,22 @@ void Explode(int ex, int ey, int phase, int mode) int frame = getGraphicAnimationFrame(graphic, phase - delay); if (phase == delay) - DrawCrumbledSand(SCREENX(x), SCREENY(y)); + DrawLevelFieldCrumbledSand(x, y); +#if 1 + if (IS_WALKABLE_OVER(Back[x][y])) + { + DrawLevelElement(x, y, Back[x][y]); + DrawGraphicThruMask(SCREENX(x), SCREENY(y), graphic, frame); + } + else if (IS_WALKABLE_UNDER(Back[x][y])) + { + DrawGraphic(SCREENX(x), SCREENY(y), graphic, frame); + DrawLevelElementThruMask(x, y, Back[x][y]); + } + else if (!IS_WALKABLE_INSIDE(Back[x][y])) + DrawGraphic(SCREENX(x), SCREENY(y), graphic, frame); +#else if (IS_PFORTE(Store[x][y])) { DrawLevelElement(x, y, Store[x][y]); @@ -1697,6 +1783,7 @@ void Explode(int ex, int ey, int phase, int mode) } else DrawGraphic(SCREENX(x), SCREENY(y), graphic, frame); +#endif } } @@ -2433,11 +2520,11 @@ void TurnRound(int x, int y) if (IN_LEV_FIELD(left_x, left_y) && (IS_FREE_OR_PLAYER(left_x, left_y) || - IS_MAMPF2(Feld[left_x][left_y]))) + IS_FOOD_DARK_YAMYAM(Feld[left_x][left_y]))) can_turn_left = TRUE; if (IN_LEV_FIELD(right_x, right_y) && (IS_FREE_OR_PLAYER(right_x, right_y) || - IS_MAMPF2(Feld[right_x][right_y]))) + IS_FOOD_DARK_YAMYAM(Feld[right_x][right_y]))) can_turn_right = TRUE; if (can_turn_left && can_turn_right) @@ -2724,7 +2811,7 @@ void TurnRound(int x, int y) Feld[newx][newy] == EL_ACID || (element == EL_PENGUIN && (Feld[newx][newy] == EL_EXIT_OPEN || - IS_MAMPF3(Feld[newx][newy]))))) + IS_FOOD_PENGUIN(Feld[newx][newy]))))) return; MovDir[x][y] = @@ -2736,7 +2823,7 @@ void TurnRound(int x, int y) Feld[newx][newy] == EL_ACID || (element == EL_PENGUIN && (Feld[newx][newy] == EL_EXIT_OPEN || - IS_MAMPF3(Feld[newx][newy]))))) + IS_FOOD_PENGUIN(Feld[newx][newy]))))) return; MovDir[x][y] = old_move_dir; @@ -3026,8 +3113,8 @@ void StartMoving(int x, int y) if (!MovDelay[x][y]) /* start new movement phase */ { - /* all objects that can change their move direction after each step */ - /* (MAMPFER, MAMPFER2 and PACMAN go straight until they hit a wall */ + /* all objects that can change their move direction after each step + (YAMYAM, DARK_YAMYAM and PACMAN go straight until they hit a wall */ if (element != EL_YAMYAM && element != EL_DARK_YAMYAM && @@ -3154,7 +3241,7 @@ void StartMoving(int x, int y) return; } - else if (IS_MAMPF3(Feld[newx][newy])) + else if (IS_FOOD_PENGUIN(Feld[newx][newy])) { if (DigField(local_player, newx, newy, 0, 0, DF_DIG) == MF_MOVING) DrawLevelField(newx, newy); @@ -3249,7 +3336,7 @@ void StartMoving(int x, int y) PlaySoundLevel(x, y, SND_YAMYAM_DIGGING); } else if (element == EL_DARK_YAMYAM && IN_LEV_FIELD(newx, newy) && - IS_MAMPF2(Feld[newx][newy])) + IS_FOOD_DARK_YAMYAM(Feld[newx][newy])) { if (AmoebaNr[newx][newy]) { @@ -3397,7 +3484,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 "DrawCrumbledSand()" */ + DrawLevelField(xx, yy); /* for "crumbled sand" */ } } @@ -4382,7 +4469,7 @@ static void ChangeActiveTrap(int x, int y) /* if new animation frame was drawn, correct crumbled sand border */ if (IS_NEW_FRAME(GfxFrame[x][y], graphic)) - DrawCrumbledSand(SCREENX(x), SCREENY(y)); + DrawLevelFieldCrumbledSand(x, y); } static void ChangeElement(int x, int y) @@ -5034,11 +5121,18 @@ static void CheckGravityMovement(struct PlayerInfo *player) if (field_under_player_is_free && !player_is_moving_to_valid_field && - !IS_TUBE(Feld[jx][jy])) + !IS_WALKABLE_INSIDE(Feld[jx][jy])) player->programmed_action = MV_DOWN; } } +/* + MoveFigureOneStep() + ----------------------------------------------------------------------------- + dx, dy: direction (non-diagonal) to try to move the player to + real_dx, real_dy: direction as read from input device (can be diagonal) +*/ + boolean MoveFigureOneStep(struct PlayerInfo *player, int dx, int dy, int real_dx, int real_dy) { @@ -5253,7 +5347,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 "DrawCrumbledSand()" */ + DrawLevelField(jx, jy); /* for "crumbled sand" */ player->last_move_dir = player->MovDir; player->is_moving = TRUE; @@ -5313,7 +5407,7 @@ void ScrollFigure(struct PlayerInfo *player, int mode) if (player->MovPos == 0) { - if (IS_QUICK_GATE(Feld[last_jx][last_jy])) + if (IS_PASSABLE(Feld[last_jx][last_jy])) { /* continue with normal speed after quickly moving through gate */ HALVE_PLAYER_SPEED(player); @@ -5601,8 +5695,13 @@ void KillHero(struct PlayerInfo *player) if (!player->active) return; +#if 1 + /* remove accessible field at the player's position */ + Feld[jx][jy] = EL_EMPTY; +#else if (IS_PFORTE(Feld[jx][jy])) Feld[jx][jy] = EL_EMPTY; +#endif /* deactivate shield (else Bang()/Explode() would not work right) */ player->shield_normal_time_left = 0; @@ -5654,6 +5753,25 @@ void RemoveHero(struct PlayerInfo *player) ExitY = ZY = jy; } +#if 0 +/* + checkDiagonalPushing() + ----------------------------------------------------------------------------- + check if diagonal input device direction results in pushing of object +*/ + +static boolean checkDiagonalPushing(int x, int y, int real_dx, int real_dy) +{ +} +#endif + +/* + DigField() + ----------------------------------------------------------------------------- + x, y: field next to player (non-diagonal) to try to dig to + real_dx, real_dy: direction as read from input device (can be diagonal) +*/ + int DigField(struct PlayerInfo *player, int x, int y, int real_dx, int real_dy, int mode) { @@ -5726,11 +5844,14 @@ int DigField(struct PlayerInfo *player, case EL_SP_BASE: case EL_SP_BUGGY_BASE: case EL_SP_BUGGY_BASE_ACTIVATING: + RemoveField(x, y); #if 1 - if (mode != DF_SNAP && element == EL_SAND) - GfxElement[x][y] = Feld[x][y]; + if (mode != DF_SNAP && element != EL_EMPTY) + { + GfxElement[x][y] = (CAN_BE_CRUMBLED(element) ? EL_SAND : element); + player->is_digging = TRUE; + } #endif - RemoveField(x, y); PlaySoundLevelElementAction(x, y, element, ACTION_DIGGING); break; @@ -5744,6 +5865,13 @@ int DigField(struct PlayerInfo *player, case EL_PEARL: case EL_CRYSTAL: RemoveField(x, y); +#if 1 + if (mode != DF_SNAP) + { + GfxElement[x][y] = element; + player->is_collecting = TRUE; + } +#endif local_player->gems_still_needed -= (element == EL_DIAMOND ? 3 : element == EL_PEARL ? 5 : element == EL_CRYSTAL ? 8 : 1); @@ -6092,16 +6220,16 @@ int DigField(struct PlayerInfo *player, break; case EL_SP_PORT_LEFT: - case EL_SP_GRAVITY_PORT_LEFT: case EL_SP_PORT_RIGHT: - case EL_SP_GRAVITY_PORT_RIGHT: case EL_SP_PORT_UP: - case EL_SP_GRAVITY_PORT_UP: case EL_SP_PORT_DOWN: - case EL_SP_GRAVITY_PORT_DOWN: case EL_SP_PORT_HORIZONTAL: case EL_SP_PORT_VERTICAL: case EL_SP_PORT_ANY: + case EL_SP_GRAVITY_PORT_LEFT: + case EL_SP_GRAVITY_PORT_RIGHT: + case EL_SP_GRAVITY_PORT_UP: + case EL_SP_GRAVITY_PORT_DOWN: if ((dx == -1 && element != EL_SP_PORT_LEFT && element != EL_SP_GRAVITY_PORT_LEFT && @@ -6374,12 +6502,7 @@ int DigField(struct PlayerInfo *player, player->push_delay = 0; if (Feld[x][y] != element) /* really digged/collected something */ - { - if (GfxElement[x][y] == EL_SAND) - player->is_digging = TRUE; - else - player->is_collecting = TRUE; - } + player->is_collecting = !player->is_digging; return MF_MOVING; } @@ -6447,7 +6570,13 @@ boolean PlaceBomb(struct PlayerInfo *player) return FALSE; if (element != EL_EMPTY) + { +#if 0 Store[jx][jy] = element; +#else + Back[jx][jy] = element; +#endif + } MovDelay[jx][jy] = 96; @@ -6610,22 +6739,22 @@ void RaiseScoreElement(int element) case EL_EMERALD_YELLOW: case EL_EMERALD_RED: case EL_EMERALD_PURPLE: - RaiseScore(level.score[SC_EDELSTEIN]); + RaiseScore(level.score[SC_EMERALD]); break; case EL_DIAMOND: - RaiseScore(level.score[SC_DIAMANT]); + RaiseScore(level.score[SC_DIAMOND]); break; case EL_BUG: case EL_BD_BUTTERFLY: - RaiseScore(level.score[SC_KAEFER]); + RaiseScore(level.score[SC_BUG]); break; case EL_SPACESHIP: case EL_BD_FIREFLY: - RaiseScore(level.score[SC_FLIEGER]); + RaiseScore(level.score[SC_SPACESHIP]); break; case EL_YAMYAM: case EL_DARK_YAMYAM: - RaiseScore(level.score[SC_MAMPFER]); + RaiseScore(level.score[SC_YAMYAM]); break; case EL_ROBOT: RaiseScore(level.score[SC_ROBOT]); @@ -6634,16 +6763,16 @@ void RaiseScoreElement(int element) RaiseScore(level.score[SC_PACMAN]); break; case EL_NUT: - RaiseScore(level.score[SC_KOKOSNUSS]); + RaiseScore(level.score[SC_NUT]); break; case EL_DYNAMITE: - RaiseScore(level.score[SC_DYNAMIT]); + RaiseScore(level.score[SC_DYNAMITE]); break; case EL_KEY_1: case EL_KEY_2: case EL_KEY_3: case EL_KEY_4: - RaiseScore(level.score[SC_SCHLUESSEL]); + RaiseScore(level.score[SC_KEY]); break; default: break;