X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=e70afad3b73a8ce6cdd64c2721c366cb664cf6c9;hb=84c20a81b20d9a4017f7691dda78fc3b6f2dedf5;hp=dc992f2573674d3a11831b92827c8434729b6167;hpb=67758fda340e825f188fc6a4caad03381bf031dc;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index dc992f25..e70afad3 100644 --- a/src/game.c +++ b/src/game.c @@ -91,15 +91,21 @@ #define SC_SCHLUESSEL 9 #define SC_ZEITBONUS 10 -/* values for game_emulation */ -#define EMU_NONE 0 -#define EMU_BOULDERDASH 1 -#define EMU_SOKOBAN 2 -#define EMU_SUPAPLEX 3 +/* game button identifiers */ +#define GAME_CTRL_ID_STOP 0 +#define GAME_CTRL_ID_PAUSE 1 +#define GAME_CTRL_ID_PLAY 2 +#define SOUND_CTRL_ID_MUSIC 3 +#define SOUND_CTRL_ID_LOOPS 4 +#define SOUND_CTRL_ID_SIMPLE 5 -/* to control special behaviour of certain game elements */ -int game_emulation = EMU_NONE; +#define NUM_GAME_BUTTONS 6 +/* forward declaration for internal use */ +static void MapGameButtons(); +static void HandleGameButtons(struct GadgetInfo *); + +static struct GadgetInfo *game_gadget[NUM_GAME_BUTTONS]; @@ -306,6 +312,19 @@ static void InitField(int x, int y, boolean init_game) Feld[x][y] = EL_LEERRAUM; break; + case EL_EM_KEY_1_FILE: + Feld[x][y] = EL_EM_KEY_1; + break; + case EL_EM_KEY_2_FILE: + Feld[x][y] = EL_EM_KEY_2; + break; + case EL_EM_KEY_3_FILE: + Feld[x][y] = EL_EM_KEY_3; + break; + case EL_EM_KEY_4_FILE: + Feld[x][y] = EL_EM_KEY_4; + break; + default: break; } @@ -333,6 +352,7 @@ void InitGame() player->action = 0; player->effective_action = 0; + player->programmed_action = 0; player->score = 0; player->gems_still_needed = level.edelsteine; @@ -365,6 +385,7 @@ void InitGame() player->move_delay = 0; player->last_move_dir = MV_NO_MOVING; + player->move_speed = (level.double_speed ? 4 : 8); player->snapped = FALSE; player->gone = FALSE; @@ -392,22 +413,19 @@ void InitGame() MampferNr = 0; FrameCounter = 0; TimeFrames = 0; + TimePlayed = 0; TimeLeft = level.time; ScreenMovDir = MV_NO_MOVING; ScreenMovPos = 0; ScreenGfxPos = 0; - if (level.high_speed) - { - MoveSpeed = 4; - ScrollStepSize = TILEX/4; - } - else - { - MoveSpeed = 8; - ScrollStepSize = TILEX/8; - } + /* + MoveSpeed = (level.double_speed ? 4 : 8); + ScrollStepSize = TILEX / MoveSpeed; + */ + + ScrollStepSize = 0; AllPlayersGone = FALSE; SiebAktiv = FALSE; @@ -543,15 +561,40 @@ void InitGame() emulate_sb ? EMU_SOKOBAN : emulate_sp ? EMU_SUPAPLEX : EMU_NONE); - scroll_x = scroll_y = -1; - if (local_player->jx >= MIDPOSX-1) - scroll_x = (local_player->jx <= lev_fieldx-MIDPOSX ? + /* determine border element for this level */ + SetBorderElement(); + + if (BorderElement == EL_LEERRAUM) + { + SBX_Left = 0; + SBX_Right = lev_fieldx - SCR_FIELDX; + SBY_Upper = 0; + SBY_Lower = lev_fieldy - SCR_FIELDY; + } + else + { + SBX_Left = -1; + SBX_Right = lev_fieldx - SCR_FIELDX + 1; + SBY_Upper = -1; + SBY_Lower = lev_fieldy - SCR_FIELDY + 1; + } + + if (lev_fieldx + (SBX_Left == -1 ? 2 : 0) <= SCR_FIELDX) + SBX_Left = SBX_Right = -1 * (SCR_FIELDX - lev_fieldx) / 2; + + if (lev_fieldy + (SBY_Upper == -1 ? 2 : 0) <= SCR_FIELDY) + SBY_Upper = SBY_Lower = -1 * (SCR_FIELDY - lev_fieldy) / 2; + + scroll_x = SBX_Left; + scroll_y = SBY_Upper; + if (local_player->jx >= SBX_Left + MIDPOSX) + scroll_x = (local_player->jx <= SBX_Right + MIDPOSX ? local_player->jx - MIDPOSX : - lev_fieldx - SCR_FIELDX + 1); - if (local_player->jy >= MIDPOSY-1) - scroll_y = (local_player->jy <= lev_fieldy-MIDPOSY ? + SBX_Right); + if (local_player->jy >= SBY_Upper + MIDPOSY) + scroll_y = (local_player->jy <= SBY_Lower + MIDPOSY ? local_player->jy - MIDPOSY : - lev_fieldy - SCR_FIELDY + 1); + SBY_Lower); CloseDoor(DOOR_CLOSE_1); @@ -578,19 +621,33 @@ void InitGame() DOOR_GFX_PAGEX1 + XX_TIME, DOOR_GFX_PAGEY1 + YY_TIME, int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); + + +#if 0 DrawGameButton(BUTTON_GAME_STOP); DrawGameButton(BUTTON_GAME_PAUSE); DrawGameButton(BUTTON_GAME_PLAY); DrawSoundDisplay(BUTTON_SOUND_MUSIC | (setup.sound_music ? BUTTON_ON : 0)); DrawSoundDisplay(BUTTON_SOUND_LOOPS | (setup.sound_loops ? BUTTON_ON : 0)); DrawSoundDisplay(BUTTON_SOUND_SIMPLE | (setup.sound_simple ? BUTTON_ON : 0)); +#else + UnmapGameButtons(); + game_gadget[SOUND_CTRL_ID_MUSIC]->checked = setup.sound_music; + game_gadget[SOUND_CTRL_ID_LOOPS]->checked = setup.sound_loops; + game_gadget[SOUND_CTRL_ID_SIMPLE]->checked = setup.sound_simple; + MapGameButtons(); + MapTapeButtons(); +#endif + XCopyArea(display, drawto, pix[PIX_DB_DOOR], gc, DX + GAME_CONTROL_XPOS, DY + GAME_CONTROL_YPOS, GAME_CONTROL_XSIZE, 2 * GAME_CONTROL_YSIZE, DOOR_GFX_PAGEX1 + GAME_CONTROL_XPOS, DOOR_GFX_PAGEY1 + GAME_CONTROL_YPOS); - OpenDoor(DOOR_OPEN_1); + + + OpenDoor(DOOR_OPEN_ALL); if (setup.sound_music) PlaySoundLoop(background_loop[level_nr % num_bg_loops]); @@ -744,7 +801,7 @@ void GameWon() { if (!setup.sound_loops) PlaySoundStereo(SND_SIRR, PSND_MAX_RIGHT); - if (TimeLeft && !(TimeLeft % 10)) + if (TimeLeft > 0 && !(TimeLeft % 10)) RaiseScore(level.score[SC_ZEITBONUS]); if (TimeLeft > 100 && !(TimeLeft % 10)) TimeLeft -= 10; @@ -758,6 +815,29 @@ void GameWon() if (setup.sound_loops) StopSound(SND_SIRR); } + else if (level.time == 0) /* level without time limit */ + { + if (setup.sound_loops) + PlaySoundExt(SND_SIRR, PSND_MAX_VOLUME, PSND_MAX_RIGHT, PSND_LOOP); + + while(TimePlayed < 999) + { + if (!setup.sound_loops) + PlaySoundStereo(SND_SIRR, PSND_MAX_RIGHT); + if (TimePlayed < 999 && !(TimePlayed % 10)) + RaiseScore(level.score[SC_ZEITBONUS]); + if (TimePlayed < 900 && !(TimePlayed % 10)) + TimePlayed += 10; + else + TimePlayed++; + DrawText(DX_TIME, DY_TIME, int2str(TimePlayed, 3), FS_SMALL, FC_YELLOW); + BackToFront(); + Delay(10); + } + + if (setup.sound_loops) + StopSound(SND_SIRR); + } FadeSounds(); @@ -794,7 +874,7 @@ void GameWon() BackToFront(); } -boolean NewHiScore() +int NewHiScore() { int k, l; int position = -1; @@ -907,6 +987,29 @@ int MovingOrBlocked2Element(int x, int y) return element; } +static int MovingOrBlocked2ElementIfNotLeaving(int x, int y) +{ + /* like MovingOrBlocked2Element(), but if element is moving + and (x,y) is the field the moving element is just leaving, + return EL_BLOCKED instead of the element value */ + int element = Feld[x][y]; + + if (IS_MOVING(x, y)) + { + if (element == EL_BLOCKED) + { + int oldx, oldy; + + Blocked2Moving(x, y, &oldx, &oldy); + return Feld[oldx][oldy]; + } + else + return EL_BLOCKED; + } + else + return element; +} + static void RemoveField(int x, int y) { Feld[x][y] = EL_LEERRAUM; @@ -978,7 +1081,9 @@ void DrawDynamite(int x, int y) phase = 7 - phase; } - if (Store[x][y]) + if (game_emulation == EMU_SUPAPLEX) + DrawGraphic(sx, sy, GFX_SP_DISK_RED); + else if (Store[x][y]) DrawGraphicThruMask(sx, sy, graphic + phase); else DrawGraphic(sx, sy, graphic + phase); @@ -1013,6 +1118,7 @@ void Explode(int ex, int ey, int phase, int mode) int num_phase = 9, delay = 2; int last_phase = num_phase * delay; int half_phase = (num_phase / 2) * delay; + int first_phase_after_start = EX_PHASE_START + 1; if (phase == EX_PHASE_START) /* initialize 'Store[][]' field */ { @@ -1034,7 +1140,7 @@ void Explode(int ex, int ey, int phase, int mode) RemoveMovingField(x, y); } - if (!IN_LEV_FIELD(x, y) || IS_MASSIV(element) || element == EL_BURNING) + if (!IN_LEV_FIELD(x, y) || IS_MASSIVE(element) || element == EL_BURNING) continue; if ((mode!=EX_NORMAL || center_element == EL_AMOEBA2DIAM) && @@ -1127,9 +1233,20 @@ void Explode(int ex, int ey, int phase, int mode) x = ex; y = ey; - Frame[x][y] = (phaseframe_reset_delay > MoveSpeed) player->Frame = 0; + */ + + if (++player->frame_reset_delay > player->move_speed) + player->Frame = 0; } if (tape.recording && num_stored_actions >= MAX_PLAYERS && save_tape_entry) @@ -3370,6 +3566,22 @@ void GameActions() { int actual_player_action = stored_player[i].effective_action; + if (stored_player[i].programmed_action) + { + /* this is very bad and need to be fixed!!! */ + unsigned long move_delay = stored_player[i].move_delay; + + /* + if (FrameReached(&move_delay, MoveSpeed)) + */ + + if (FrameReached(&move_delay, stored_player[i].move_speed)) + { + actual_player_action = stored_player[i].programmed_action; + stored_player[i].programmed_action = 0; + } + } + if (recorded_player_action) actual_player_action = recorded_player_action[i]; @@ -3400,9 +3612,9 @@ void GameActions() extern unsigned int last_RND(); printf("DEBUG: %03d last RND was %d \t [state checksum is %d]\n", - level.time - TimeLeft, + TimePlayed, last_RND(), - getStateCheckSum(level.time - TimeLeft)); + getStateCheckSum(TimePlayed)); } */ #endif @@ -3495,10 +3707,12 @@ void GameActions() MauerAbleger(x, y); else if (element == EL_BURNING) CheckForDragon(x, y); + else if (element == EL_SP_BUG || element == EL_SP_BUG_ACTIVE) + CheckBuggyBase(x, y); else if (element == EL_SP_TERMINAL) - DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL, 7, 10, ANIM_NORMAL); + DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL, 7, 12, ANIM_NORMAL); else if (element == EL_SP_TERMINAL_ACTIVE) - DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL_ACTIVE, 7, 2, ANIM_NORMAL); + DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL_ACTIVE, 7, 4, ANIM_NORMAL); if (SiebAktiv) { @@ -3557,22 +3771,29 @@ void GameActions() } } - if (TimeLeft > 0 && TimeFrames >= (1000 / GameFrameDelay) && !tape.pausing) + if (TimeFrames >= (1000 / GameFrameDelay) && !tape.pausing) { TimeFrames = 0; - TimeLeft--; + TimePlayed++; if (tape.recording || tape.playing) - DrawVideoDisplay(VIDEO_STATE_TIME_ON, level.time-TimeLeft); + DrawVideoDisplay(VIDEO_STATE_TIME_ON, TimePlayed); - if (TimeLeft<=10) - PlaySoundStereo(SND_GONG, PSND_MAX_RIGHT); + if (TimeLeft > 0) + { + TimeLeft--; - DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); + if (TimeLeft <= 10) + PlaySoundStereo(SND_GONG, PSND_MAX_RIGHT); - if (!TimeLeft) - for (i=0; ijy = new_jy; StorePlayer[jx][jy] = player->element_nr; + /* player->MovPos = (dx > 0 || dy > 0 ? -1 : 1) * (TILEX - TILEX / MoveSpeed); + */ + + player->MovPos = + (dx > 0 || dy > 0 ? -1 : 1) * (TILEX - TILEX / player->move_speed); ScrollFigure(player, SCROLL_INIT); @@ -3715,22 +3945,36 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy) if (player->gone || (!dx && !dy)) return FALSE; + /* if (!FrameReached(&player->move_delay, MoveSpeed) && !tape.playing) return FALSE; + */ + + if (!FrameReached(&player->move_delay, player->move_speed) && !tape.playing) + return FALSE; if (player->MovPos) { /* should only happen if pre-1.2 tape recordings are played */ /* this is only for backward compatibility */ + /* int old_move_speed = MoveSpeed; + */ + + int old_move_speed = player->move_speed; #if DEBUG printf("THIS SHOULD ONLY HAPPEN WITH PRE-1.2 LEVEL TAPES.\n"); #endif /* scroll remaining steps with finest movement resolution */ + + /* MoveSpeed = 8; + */ + + player->move_speed = 8; while (player->MovPos) { @@ -3741,7 +3985,12 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy) BackToFront(); } + /* MoveSpeed = old_move_speed; + */ + + player->move_speed = old_move_speed; + } if (player->last_move_dir & (MV_LEFT | MV_RIGHT)) @@ -3776,13 +4025,13 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy) { if (jx != old_jx) /* player has moved horizontally */ { - if ((player->MovDir == MV_LEFT && scroll_x > jx-MIDPOSX+offset) || - (player->MovDir == MV_RIGHT && scroll_x < jx-MIDPOSX-offset)) + if ((player->MovDir == MV_LEFT && scroll_x > jx - MIDPOSX + offset) || + (player->MovDir == MV_RIGHT && scroll_x < jx - MIDPOSX - offset)) scroll_x = jx-MIDPOSX + (scroll_x < jx-MIDPOSX ? -offset : +offset); /* don't scroll over playfield boundaries */ - if (scroll_x < -1 || scroll_x > lev_fieldx - SCR_FIELDX + 1) - scroll_x = (scroll_x < -1 ? -1 : lev_fieldx - SCR_FIELDX + 1); + if (scroll_x < SBX_Left || scroll_x > SBX_Right) + scroll_x = (scroll_x < SBX_Left ? SBX_Left : SBX_Right); /* don't scroll more than one field at a time */ scroll_x = old_scroll_x + SIGN(scroll_x - old_scroll_x); @@ -3794,13 +4043,13 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy) } else /* player has moved vertically */ { - if ((player->MovDir == MV_UP && scroll_y > jy-MIDPOSY+offset) || - (player->MovDir == MV_DOWN && scroll_y < jy-MIDPOSY-offset)) + if ((player->MovDir == MV_UP && scroll_y > jy - MIDPOSY + offset) || + (player->MovDir == MV_DOWN && scroll_y < jy - MIDPOSY - offset)) scroll_y = jy-MIDPOSY + (scroll_y < jy-MIDPOSY ? -offset : +offset); /* don't scroll over playfield boundaries */ - if (scroll_y < -1 || scroll_y > lev_fieldy - SCR_FIELDY + 1) - scroll_y = (scroll_y < -1 ? -1 : lev_fieldy - SCR_FIELDY + 1); + if (scroll_y < SBY_Upper || scroll_y > SBY_Lower) + scroll_y = (scroll_y < SBY_Upper ? SBY_Upper : SBY_Lower); /* don't scroll more than one field at a time */ scroll_y = old_scroll_y + SIGN(scroll_y - old_scroll_y); @@ -3858,6 +4107,7 @@ void ScrollFigure(struct PlayerInfo *player, int mode) { int jx = player->jx, jy = player->jy; int last_jx = player->last_jx, last_jy = player->last_jy; + int move_stepsize = TILEX / player->move_speed; if (!player->active || player->gone || !player->MovPos) return; @@ -3865,7 +4115,7 @@ void ScrollFigure(struct PlayerInfo *player, int mode) if (mode == SCROLL_INIT) { player->actual_frame_counter = FrameCounter; - player->GfxPos = ScrollStepSize * (player->MovPos / ScrollStepSize); + player->GfxPos = move_stepsize * (player->MovPos / move_stepsize); if (Feld[last_jx][last_jy] == EL_LEERRAUM) Feld[last_jx][last_jy] = EL_PLAYER_IS_LEAVING; @@ -3876,8 +4126,8 @@ void ScrollFigure(struct PlayerInfo *player, int mode) else if (!FrameReached(&player->actual_frame_counter, 1)) return; - player->MovPos += (player->MovPos > 0 ? -1 : 1) * TILEX / MoveSpeed; - player->GfxPos = ScrollStepSize * (player->MovPos / ScrollStepSize); + player->MovPos += (player->MovPos > 0 ? -1 : 1) * move_stepsize; + player->GfxPos = move_stepsize * (player->MovPos / move_stepsize); if (Feld[last_jx][last_jy] == EL_PLAYER_IS_LEAVING) Feld[last_jx][last_jy] = EL_LEERRAUM; @@ -3886,6 +4136,23 @@ void ScrollFigure(struct PlayerInfo *player, int mode) if (!player->MovPos) { + if (IS_QUICK_GATE(Feld[last_jx][last_jy])) + { + /* continue with normal speed after moving through port */ + /* FIX THIS: what about player already having eaten a speed pill? */ + + /* + MoveSpeed = 8; + ScrollStepSize = TILEX / MoveSpeed; + */ + + player->move_speed = 8; + + /* don't wait for the next move -- the whole move delay stuff + is worse at the moment; FIX THIS! ;-) */ + player->move_delay = 0; + } + player->last_jx = jx; player->last_jy = jy; @@ -3905,6 +4172,9 @@ void ScrollScreen(struct PlayerInfo *player, int mode) if (mode == SCROLL_INIT) { + /* set scrolling step size according to actual player's moving speed */ + ScrollStepSize = TILEX / player->move_speed; + screen_frame_counter = FrameCounter; ScreenMovDir = player->MovDir; ScreenMovPos = player->MovPos; @@ -3916,7 +4186,7 @@ void ScrollScreen(struct PlayerInfo *player, int mode) if (ScreenMovPos) { - ScreenMovPos += (ScreenMovPos > 0 ? -1 : 1) * TILEX / MoveSpeed; + ScreenMovPos += (ScreenMovPos > 0 ? -1 : 1) * ScrollStepSize; ScreenGfxPos = ScrollStepSize * (ScreenMovPos / ScrollStepSize); redraw_mask |= REDRAW_FIELD; } @@ -3951,7 +4221,11 @@ void TestIfGoodThingHitsBadThing(int goodx, int goody) if (!IN_LEV_FIELD(x, y)) continue; +#if 0 element = Feld[x][y]; +#else + element = MovingOrBlocked2ElementIfNotLeaving(x, y); +#endif if (DONT_TOUCH(element)) { @@ -4134,6 +4408,10 @@ int DigField(struct PlayerInfo *player, { int jx = player->jx, jy = player->jy; int dx = x - jx, dy = y - jy; + int move_direction = (dx == -1 ? MV_LEFT : + dx == +1 ? MV_RIGHT : + dy == -1 ? MV_UP : + dy == +1 ? MV_DOWN : MV_NO_MOVING); int element; if (!player->MovPos) @@ -4153,10 +4431,18 @@ int DigField(struct PlayerInfo *player, switch(element) { case EL_LEERRAUM: + PlaySoundLevel(x, y, SND_EMPTY); break; case EL_ERDREICH: Feld[x][y] = EL_LEERRAUM; + PlaySoundLevel(x, y, SND_SCHLURF); + break; + + case EL_SP_BASE: + case EL_SP_BUG: + Feld[x][y] = EL_LEERRAUM; + PlaySoundLevel(x, y, SND_SP_BASE); break; case EL_EDELSTEIN: @@ -4174,13 +4460,22 @@ int DigField(struct PlayerInfo *player, DrawText(DX_EMERALDS, DY_EMERALDS, int2str(local_player->gems_still_needed, 3), FS_SMALL, FC_YELLOW); - PlaySoundLevel(x, y, SND_PONG); + if (element == EL_SP_INFOTRON) + PlaySoundLevel(x, y, SND_SP_INFOTRON); + else + PlaySoundLevel(x, y, SND_PONG); break; case EL_SPEED_PILL: RemoveField(x, y); + + player->move_speed = 4; + + /* MoveSpeed = 4; - ScrollStepSize = TILEX/4; + ScrollStepSize = TILEX / MoveSpeed; + */ + PlaySoundLevel(x, y, SND_PONG); break; @@ -4192,7 +4487,10 @@ int DigField(struct PlayerInfo *player, DrawText(DX_DYNAMITE, DY_DYNAMITE, int2str(local_player->dynamite, 3), FS_SMALL, FC_YELLOW); - PlaySoundLevel(x, y, SND_PONG); + if (element == EL_SP_DISK_RED) + PlaySoundLevel(x, y, SND_SP_INFOTRON); + else + PlaySoundLevel(x, y, SND_PONG); break; case EL_DYNABOMB_NR: @@ -4222,7 +4520,27 @@ int DigField(struct PlayerInfo *player, case EL_SCHLUESSEL3: case EL_SCHLUESSEL4: { - int key_nr = element-EL_SCHLUESSEL1; + int key_nr = element - EL_SCHLUESSEL1; + + RemoveField(x, y); + player->key[key_nr] = TRUE; + RaiseScoreElement(EL_SCHLUESSEL); + DrawMiniGraphicExt(drawto, gc, + DX_KEYS+key_nr*MINI_TILEX, DY_KEYS, + GFX_SCHLUESSEL1+key_nr); + DrawMiniGraphicExt(window, gc, + DX_KEYS+key_nr*MINI_TILEX, DY_KEYS, + GFX_SCHLUESSEL1+key_nr); + PlaySoundLevel(x, y, SND_PONG); + break; + } + + case EL_EM_KEY_1: + case EL_EM_KEY_2: + case EL_EM_KEY_3: + case EL_EM_KEY_4: + { + int key_nr = element - EL_EM_KEY_1; RemoveField(x, y); player->key[key_nr] = TRUE; @@ -4269,7 +4587,7 @@ int DigField(struct PlayerInfo *player, return MF_NO_ACTION; player->LevelSolved = player->GameOver = TRUE; - PlaySoundLevel(x, y, SND_BUING); + PlaySoundStereo(SND_SP_EXIT, PSND_MAX_RIGHT); break; case EL_FELSBROCKEN: @@ -4308,6 +4626,8 @@ int DigField(struct PlayerInfo *player, PlaySoundLevel(x+dx, y+dy, SND_PUSCH); else if (element == EL_KOKOSNUSS) PlaySoundLevel(x+dx, y+dy, SND_KNURK); + else if (IS_SP_ELEMENT(element)) + PlaySoundLevel(x+dx, y+dy, SND_SP_ZONKPUSH); else PlaySoundLevel(x+dx, y+dy, SND_KLOPF); break; @@ -4316,7 +4636,7 @@ int DigField(struct PlayerInfo *player, case EL_PFORTE2: case EL_PFORTE3: case EL_PFORTE4: - if (!player->key[element-EL_PFORTE1]) + if (!player->key[element - EL_PFORTE1]) return MF_NO_ACTION; break; @@ -4324,8 +4644,40 @@ int DigField(struct PlayerInfo *player, case EL_PFORTE2X: case EL_PFORTE3X: case EL_PFORTE4X: - if (!player->key[element-EL_PFORTE1X]) + if (!player->key[element - EL_PFORTE1X]) + return MF_NO_ACTION; + break; + + case EL_EM_GATE_1: + case EL_EM_GATE_2: + case EL_EM_GATE_3: + case EL_EM_GATE_4: + if (!player->key[element - EL_EM_GATE_1]) + return MF_NO_ACTION; + + if (!IN_LEV_FIELD(x + dx, y + dy) || !IS_FREE(x + dx, y + dy)) return MF_NO_ACTION; + + /* automatically move to the next field with double speed */ + player->programmed_action = move_direction; + player->move_speed = 4; + + break; + + case EL_EM_GATE_1X: + case EL_EM_GATE_2X: + case EL_EM_GATE_3X: + case EL_EM_GATE_4X: + if (!player->key[element - EL_EM_GATE_1X]) + return MF_NO_ACTION; + + if (!IN_LEV_FIELD(x + dx, y + dy) || !IS_FREE(x + dx, y + dy)) + return MF_NO_ACTION; + + /* automatically move to the next field with double speed */ + player->programmed_action = move_direction; + player->move_speed = 4; + break; case EL_SP_PORT1_LEFT: @@ -4362,6 +4714,16 @@ int DigField(struct PlayerInfo *player, !IN_LEV_FIELD(x + dx, y + dy) || !IS_FREE(x + dx, y + dy)) return MF_NO_ACTION; + + /* automatically move to the next field with double speed */ + player->programmed_action = move_direction; + player->move_speed = 4; + + /* + MoveSpeed = 4; + ScrollStepSize = TILEX / MoveSpeed; + */ + break; case EL_AUSGANG_ZU: @@ -4487,12 +4849,7 @@ int DigField(struct PlayerInfo *player, break; default: - if (IS_EATABLE(element)) /* other kinds of 'dirt' */ - Feld[x][y] = EL_LEERRAUM; - else - return MF_NO_ACTION; - - break; + return MF_NO_ACTION; } player->push_delay = 0; @@ -4561,7 +4918,12 @@ boolean PlaceBomb(struct PlayerInfo *player) DrawText(DX_DYNAMITE, DY_DYNAMITE, int2str(local_player->dynamite, 3), FS_SMALL, FC_YELLOW); if (IN_SCR_FIELD(SCREENX(jx), SCREENY(jy))) - DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), GFX_DYNAMIT); + { + if (game_emulation == EMU_SUPAPLEX) + DrawGraphic(SCREENX(jx), SCREENY(jy), GFX_SP_DISK_RED); + else + DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), GFX_DYNAMIT); + } } else { @@ -4664,3 +5026,237 @@ void RaiseScoreElement(int element) break; } } + +/* ---------- new game button stuff ---------------------------------------- */ + +/* graphic position values for game buttons */ +#define GAME_BUTTON_XSIZE 30 +#define GAME_BUTTON_YSIZE 30 +#define GAME_BUTTON_XPOS 5 +#define GAME_BUTTON_YPOS 215 +#define SOUND_BUTTON_XPOS 5 +#define SOUND_BUTTON_YPOS (GAME_BUTTON_YPOS + GAME_BUTTON_YSIZE) + +#define GAME_BUTTON_STOP_XPOS (GAME_BUTTON_XPOS + 0 * GAME_BUTTON_XSIZE) +#define GAME_BUTTON_PAUSE_XPOS (GAME_BUTTON_XPOS + 1 * GAME_BUTTON_XSIZE) +#define GAME_BUTTON_PLAY_XPOS (GAME_BUTTON_XPOS + 2 * GAME_BUTTON_XSIZE) +#define SOUND_BUTTON_MUSIC_XPOS (SOUND_BUTTON_XPOS + 0 * GAME_BUTTON_XSIZE) +#define SOUND_BUTTON_LOOPS_XPOS (SOUND_BUTTON_XPOS + 1 * GAME_BUTTON_XSIZE) +#define SOUND_BUTTON_SIMPLE_XPOS (SOUND_BUTTON_XPOS + 2 * GAME_BUTTON_XSIZE) + +static struct +{ + int x, y; + int gadget_id; + char *infotext; +} gamebutton_info[NUM_GAME_BUTTONS] = +{ + { + GAME_BUTTON_STOP_XPOS, GAME_BUTTON_YPOS, + GAME_CTRL_ID_STOP, + "stop game" + }, + { + GAME_BUTTON_PAUSE_XPOS, GAME_BUTTON_YPOS, + GAME_CTRL_ID_PAUSE, + "pause game" + }, + { + GAME_BUTTON_PLAY_XPOS, GAME_BUTTON_YPOS, + GAME_CTRL_ID_PLAY, + "play game" + }, + { + SOUND_BUTTON_MUSIC_XPOS, SOUND_BUTTON_YPOS, + SOUND_CTRL_ID_MUSIC, + "background music on/off" + }, + { + SOUND_BUTTON_LOOPS_XPOS, SOUND_BUTTON_YPOS, + SOUND_CTRL_ID_LOOPS, + "sound loops on/off" + }, + { + SOUND_BUTTON_SIMPLE_XPOS, SOUND_BUTTON_YPOS, + SOUND_CTRL_ID_SIMPLE, + "normal sounds on/off" + } +}; + +void CreateGameButtons() +{ + int i; + + for (i=0; icustom_id; + + if (game_status != PLAYING) + return; + + switch (id) + { + case GAME_CTRL_ID_STOP: + if (AllPlayersGone) + { + CloseDoor(DOOR_CLOSE_1); + game_status = MAINMENU; + DrawMainMenu(); + break; + } + + if (Request("Do you really want to quit the game ?", + REQ_ASK | REQ_STAY_CLOSED)) + { +#ifndef MSDOS + if (options.network) + SendToServer_StopPlaying(); + else +#endif + { + game_status = MAINMENU; + DrawMainMenu(); + } + } + else + OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK); + break; + + case GAME_CTRL_ID_PAUSE: + if (options.network) + { +#ifndef MSDOS + if (tape.pausing) + SendToServer_ContinuePlaying(); + else + SendToServer_PausePlaying(); +#endif + } + else + TapeTogglePause(); + break; + + case GAME_CTRL_ID_PLAY: + if (tape.pausing) + { +#ifndef MSDOS + if (options.network) + SendToServer_ContinuePlaying(); + else +#endif + { + tape.pausing = FALSE; + DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0); + } + } + break; + + case SOUND_CTRL_ID_MUSIC: + if (setup.sound_music) + { + setup.sound_music = FALSE; + FadeSound(background_loop[level_nr % num_bg_loops]); + } + else if (sound_loops_allowed) + { + setup.sound = setup.sound_music = TRUE; + PlaySoundLoop(background_loop[level_nr % num_bg_loops]); + } + break; + + case SOUND_CTRL_ID_LOOPS: + if (setup.sound_loops) + setup.sound_loops = FALSE; + else if (sound_loops_allowed) + setup.sound = setup.sound_loops = TRUE; + break; + + case SOUND_CTRL_ID_SIMPLE: + if (setup.sound_simple) + setup.sound_simple = FALSE; + else if (sound_status==SOUND_AVAILABLE) + setup.sound = setup.sound_simple = TRUE; + break; + + default: + break; + } +}