X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=c1e87624b867bf3a92a53e976a1cbbd0bee2cd48;hb=ac4c028b525860750de315d626730ac493f56944;hp=338e670b5f686b818847cef68dc46279d0cbfd7e;hpb=5ae04ac2ef54f6f164a797c16c9782042cc2ce67;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index 338e670b..c1e87624 100644 --- a/src/game.c +++ b/src/game.c @@ -723,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; @@ -1378,7 +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_EMPTY; + GfxElement[x][y] = EL_UNDEFINED; MovPos[x][y] = 0; MovDir[x][y] = 0; MovDelay[x][y] = 0; @@ -1433,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); @@ -1500,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 burning dynamite */ + if (!IS_INDESTRUCTIBLE(Back[ex][ey])) + Back[ex][ey] = 0; + if (IS_MOVING(ex, ey) || IS_BLOCKED(ex, ey)) { /* put moving element to center field (and let it explode there) */ @@ -1525,7 +1534,10 @@ void Explode(int ex, int ey, int phase, int mode) RemoveMovingField(x, y); } - if (IS_INDESTRUCTIBLE(element) || element == EL_FLAMES) + if ((IS_INDESTRUCTIBLE(element) && + (game.engine_version < VERSION_IDENT(2,2,0) || + (!IS_WALKABLE_OVER(element) && !IS_WALKABLE_UNDER(element)))) || + element == EL_FLAMES) continue; if (IS_PLAYER(x, y) && SHIELD_ON(PLAYERINFO(x, y))) @@ -1540,6 +1552,11 @@ void Explode(int ex, int ey, int phase, int mode) continue; } + /* save walkable background elements while explosion on same tile */ + if (IS_INDESTRUCTIBLE(element)) + Back[x][y] = element; + + /* ignite explodable elements reached by other explosion */ if (element == EL_EXPLOSION) element = Store2[x][y]; @@ -1595,7 +1612,7 @@ 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; - else if (!IS_PFORTE(Store[x][y])) + else Store[x][y] = EL_EMPTY; if (x != ex || y != ey || @@ -1612,7 +1629,7 @@ void Explode(int ex, int ey, int phase, int mode) } Feld[x][y] = EL_EXPLOSION; - GfxElement[x][y] = EL_EMPTY; + GfxElement[x][y] = EL_UNDEFINED; MovDir[x][y] = MovPos[x][y] = 0; AmoebaNr[x][y] = 0; ExplodePhase[x][y] = 1; @@ -1666,6 +1683,11 @@ 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 (Back[x][y] && IS_INDESTRUCTIBLE(Back[x][y])) + element = Feld[x][y] = Back[x][y]; + Back[x][y] = 0; + MovDir[x][y] = MovPos[x][y] = MovDelay[x][y] = 0; InitField(x, y, FALSE); if (CAN_MOVE(element) || COULD_MOVE(element)) @@ -1686,12 +1708,17 @@ void Explode(int ex, int ey, int phase, int mode) if (phase == delay) DrawLevelFieldCrumbledSand(x, y); - if (IS_PFORTE(Store[x][y])) + if (IS_WALKABLE_OVER(Back[x][y])) { - DrawLevelElement(x, y, Store[x][y]); + DrawLevelElement(x, y, Back[x][y]); DrawGraphicThruMask(SCREENX(x), SCREENY(y), graphic, frame); } - else + 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); } } @@ -1820,6 +1847,26 @@ void SplashAcid(int x, int y) } } +static int ChangeElementOnPlayfield(int element_old, int element_new) +{ + int x, y; + int num_changes = 0; + + for(y=0; yprogrammed_action = MV_DOWN; } } @@ -5316,7 +5367,7 @@ void ScrollFigure(struct PlayerInfo *player, int mode) if (player->MovPos == 0) { - if (IS_WALKABLE_THROUGH(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); @@ -5604,8 +5655,8 @@ void KillHero(struct PlayerInfo *player) if (!player->active) return; - if (IS_PFORTE(Feld[jx][jy])) - Feld[jx][jy] = EL_EMPTY; + /* remove accessible field at the player's position */ + Feld[jx][jy] = EL_EMPTY; /* deactivate shield (else Bang()/Explode() would not work right) */ player->shield_normal_time_left = 0; @@ -5706,7 +5757,7 @@ int DigField(struct PlayerInfo *player, if (IS_MOVING(x, y) || IS_PLAYER(x, y)) return MF_NO_ACTION; - if (IS_WALKABLE_UNDER(Feld[jx][jy])) + if (IS_TUBE(Feld[jx][jy])) { int i = 0; int tube_leave_directions[][2] = @@ -5861,6 +5912,8 @@ int DigField(struct PlayerInfo *player, { int key_nr = element - EL_KEY_1; int graphic = el2edimg(element); + int element_old, element_new; + int num_changes; RemoveField(x, y); player->key[key_nr] = TRUE; @@ -5870,6 +5923,34 @@ int DigField(struct PlayerInfo *player, DrawMiniGraphicExt(window, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS, graphic); PlaySoundLevel(x, y, SND_CLASS_KEY_COLLECTING); + + element_old = EL_GATE_1_CLOSED + key_nr; + element_new = EL_GATE_1_OPEN + key_nr; + num_changes = ChangeElementOnPlayfield(element_old, element_new); + if (num_changes > 0) + PlaySoundLevelElementAction(x, y, element_old, ACTION_OPENING); + + element_old = EL_GATE_1_GRAY_CLOSED + key_nr; + element_new = EL_GATE_1_GRAY_OPEN + key_nr; + num_changes = ChangeElementOnPlayfield(element_old, element_new); + if (num_changes > 0) + PlaySoundLevelElementAction(x, y, element_old, ACTION_OPENING); + + if (game.engine_version < VERSION_IDENT(2,2,0)) + { + element_old = EL_EM_GATE_1_CLOSED + key_nr; + element_new = EL_EM_GATE_1_OPEN + key_nr; + num_changes = ChangeElementOnPlayfield(element_old, element_new); + if (num_changes > 0) + PlaySoundLevelElementAction(x, y, element_old, ACTION_OPENING); + + element_old = EL_EM_GATE_1_GRAY_CLOSED + key_nr; + element_new = EL_EM_GATE_1_GRAY_OPEN + key_nr; + num_changes = ChangeElementOnPlayfield(element_old, element_new); + if (num_changes > 0) + PlaySoundLevelElementAction(x, y, element_old, ACTION_OPENING); + } + break; } @@ -5880,6 +5961,8 @@ int DigField(struct PlayerInfo *player, { int key_nr = element - EL_EM_KEY_1; int graphic = el2edimg(EL_KEY_1 + key_nr); + int element_old, element_new; + int num_changes; RemoveField(x, y); player->key[key_nr] = TRUE; @@ -5889,6 +5972,34 @@ int DigField(struct PlayerInfo *player, DrawMiniGraphicExt(window, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS, graphic); PlaySoundLevel(x, y, SND_CLASS_KEY_COLLECTING); + + element_old = EL_EM_GATE_1_CLOSED + key_nr; + element_new = EL_EM_GATE_1_OPEN + key_nr; + num_changes = ChangeElementOnPlayfield(element_old, element_new); + if (num_changes > 0) + PlaySoundLevelElementAction(x, y, element_old, ACTION_OPENING); + + element_old = EL_EM_GATE_1_GRAY_CLOSED + key_nr; + element_new = EL_EM_GATE_1_GRAY_OPEN + key_nr; + num_changes = ChangeElementOnPlayfield(element_old, element_new); + if (num_changes > 0) + PlaySoundLevelElementAction(x, y, element_old, ACTION_OPENING); + + if (game.engine_version < VERSION_IDENT(2,2,0)) + { + element_old = EL_GATE_1_CLOSED + key_nr; + element_new = EL_GATE_1_OPEN + key_nr; + num_changes = ChangeElementOnPlayfield(element_old, element_new); + if (num_changes > 0) + PlaySoundLevelElementAction(x, y, element_old, ACTION_OPENING); + + element_old = EL_GATE_1_GRAY_CLOSED + key_nr; + element_new = EL_GATE_1_GRAY_OPEN + key_nr; + num_changes = ChangeElementOnPlayfield(element_old, element_new); + if (num_changes > 0) + PlaySoundLevelElementAction(x, y, element_old, ACTION_OPENING); + } + break; } @@ -6059,28 +6170,34 @@ int DigField(struct PlayerInfo *player, PlaySoundLevelElementAction(x, y, element, ACTION_PUSHING); break; - case EL_GATE_1: - case EL_GATE_2: - case EL_GATE_3: - case EL_GATE_4: + case EL_GATE_1_OPEN: + case EL_GATE_2_OPEN: + case EL_GATE_3_OPEN: + case EL_GATE_4_OPEN: +#if 0 if (!player->key[element - EL_GATE_1]) return MF_NO_ACTION; +#endif break; - case EL_GATE_1_GRAY: - case EL_GATE_2_GRAY: - case EL_GATE_3_GRAY: - case EL_GATE_4_GRAY: + case EL_GATE_1_GRAY_OPEN: + case EL_GATE_2_GRAY_OPEN: + case EL_GATE_3_GRAY_OPEN: + case EL_GATE_4_GRAY_OPEN: +#if 0 if (!player->key[element - EL_GATE_1_GRAY]) return MF_NO_ACTION; +#endif break; - case EL_EM_GATE_1: - case EL_EM_GATE_2: - case EL_EM_GATE_3: - case EL_EM_GATE_4: + case EL_EM_GATE_1_OPEN: + case EL_EM_GATE_2_OPEN: + case EL_EM_GATE_3_OPEN: + case EL_EM_GATE_4_OPEN: +#if 0 if (!player->key[element - EL_EM_GATE_1]) return MF_NO_ACTION; +#endif if (!IN_LEV_FIELD(x + dx, y + dy) || !IS_FREE(x + dx, y + dy)) return MF_NO_ACTION; @@ -6088,15 +6205,21 @@ int DigField(struct PlayerInfo *player, player->programmed_action = move_direction; DOUBLE_PLAYER_SPEED(player); +#if 1 + PlaySoundLevelAction(x, y, ACTION_PASSING); +#else PlaySoundLevel(x, y, SND_CLASS_GATE_PASSING); +#endif break; - case EL_EM_GATE_1_GRAY: - case EL_EM_GATE_2_GRAY: - case EL_EM_GATE_3_GRAY: - case EL_EM_GATE_4_GRAY: + case EL_EM_GATE_1_GRAY_OPEN: + case EL_EM_GATE_2_GRAY_OPEN: + case EL_EM_GATE_3_GRAY_OPEN: + case EL_EM_GATE_4_GRAY_OPEN: +#if 0 if (!player->key[element - EL_EM_GATE_1_GRAY]) return MF_NO_ACTION; +#endif if (!IN_LEV_FIELD(x + dx, y + dy) || !IS_FREE(x + dx, y + dy)) return MF_NO_ACTION; @@ -6474,7 +6597,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;