X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=338e670b5f686b818847cef68dc46279d0cbfd7e;hb=5ae04ac2ef54f6f164a797c16c9782042cc2ce67;hp=901a7fcf427d8f7d75c4d9adba0b226a486cc553;hpb=38c26472a6e9f0f037ddfe535d3919c00772b26f;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index 901a7fcf..338e670b 100644 --- a/src/game.c +++ b/src/game.c @@ -89,6 +89,8 @@ #define DOUBLE_PLAYER_SPEED(p) (HALVE_MOVE_DELAY((p)->move_delay_value)) #define HALVE_PLAYER_SPEED(p) (DOUBLE_MOVE_DELAY((p)->move_delay_value)) +#define INIT_GFX_RANDOM() (SimpleRND(1000000)) + /* game button identifiers */ #define GAME_CTRL_ID_STOP 0 #define GAME_CTRL_ID_PAUSE 1 @@ -99,7 +101,9 @@ #define NUM_GAME_BUTTONS 6 + /* forward declaration for internal use */ + static void InitBeltMovement(void); static void CloseAllOpenTimegates(void); static void CheckGravityMovement(struct PlayerInfo *); @@ -109,67 +113,20 @@ static void PlaySoundLevel(int, int, int); static void PlaySoundLevelNearest(int, int, int); static void PlaySoundLevelAction(int, int, int); static void PlaySoundLevelElementAction(int, int, int, int); +static void PlaySoundLevelActionIfLoop(int, int, int); +static void StopSoundLevelActionIfLoop(int, int, int); static void MapGameButtons(); static void HandleGameButtons(struct GadgetInfo *); static struct GadgetInfo *game_gadget[NUM_GAME_BUTTONS]; -#define IS_ANIMATED(g) (new_graphic_info[g].anim_frames > 1) - /* ------------------------------------------------------------------------- */ -/* sound definitions */ +/* definition of elements that automatically change to other elements after */ +/* a specified time, eventually calling a function when changing */ /* ------------------------------------------------------------------------- */ -#define SND_ACTION_UNKNOWN 0 -#define SND_ACTION_WAITING 1 -#define SND_ACTION_MOVING 2 -#define SND_ACTION_DIGGING 3 -#define SND_ACTION_COLLECTING 4 -#define SND_ACTION_PASSING 5 -#define SND_ACTION_IMPACT 6 -#define SND_ACTION_PUSHING 7 -#define SND_ACTION_ACTIVATING 8 -#define SND_ACTION_ACTIVE 9 - -#define NUM_SND_ACTIONS 10 - -static struct -{ - char *text; - int value; - boolean is_loop; -} sound_action_properties[] = -{ - /* insert _all_ loop sound actions here */ - { ".waiting", SND_ACTION_WAITING, TRUE }, - { ".moving", SND_ACTION_MOVING, TRUE }, /* continuos moving */ - { ".active", SND_ACTION_ACTIVE, TRUE }, - { ".growing", SND_ACTION_UNKNOWN, TRUE }, - { ".attacking", SND_ACTION_UNKNOWN, TRUE }, - - /* other (non-loop) sound actions are optional */ - { ".stepping", SND_ACTION_MOVING, FALSE }, /* discrete moving */ - { ".digging", SND_ACTION_DIGGING, FALSE }, - { ".collecting", SND_ACTION_COLLECTING, FALSE }, - { ".passing", SND_ACTION_PASSING, FALSE }, - { ".impact", SND_ACTION_IMPACT, FALSE }, - { ".pushing", SND_ACTION_PUSHING, FALSE }, - { ".activating", SND_ACTION_ACTIVATING, FALSE }, - { NULL, 0, 0 }, -}; -static int element_action_sound[MAX_NUM_ELEMENTS][NUM_SND_ACTIONS]; -static boolean is_loop_sound[NUM_SOUND_FILES]; - -#define IS_LOOP_SOUND(x) (is_loop_sound[x]) - - -/* ------------------------------------------------------------------------- - definition of elements that automatically change to other elements after - a specified time, eventually calling a function when changing - ------------------------------------------------------------------------- */ - /* forward declaration for changer functions */ static void InitBuggyBase(int x, int y); static void WarnBuggyBase(int x, int y); @@ -197,7 +154,7 @@ struct ChangingElementInfo static struct ChangingElementInfo changing_element_list[] = { - { EL_NUT_CRACKING, EL_EMERALD, 6, NULL, NULL, NULL }, + { EL_NUT_BREAKING, EL_EMERALD, 6, NULL, NULL, NULL }, { EL_PEARL_BREAKING, EL_EMPTY, 8, NULL, NULL, NULL }, { EL_EXIT_OPENING, EL_EXIT_OPEN, 29, NULL, NULL, NULL }, @@ -207,6 +164,9 @@ static struct ChangingElementInfo changing_element_list[] = { EL_TIMEGATE_OPENING, EL_TIMEGATE_OPEN, 29, NULL, NULL, NULL }, { EL_TIMEGATE_CLOSING, EL_TIMEGATE_CLOSED, 29, NULL, NULL, NULL }, + { EL_ACID_SPLASH_LEFT, EL_EMPTY, 8, NULL, NULL, NULL }, + { EL_ACID_SPLASH_RIGHT, EL_EMPTY, 8, NULL, NULL, NULL }, + { EL_SP_BUGGY_BASE, EL_SP_BUGGY_BASE_ACTIVATING, 0, InitBuggyBase, NULL, NULL }, { EL_SP_BUGGY_BASE_ACTIVATING,EL_SP_BUGGY_BASE_ACTIVE, 0, @@ -233,60 +193,6 @@ static struct ChangingElementInfo changing_element[MAX_NUM_ELEMENTS]; #define IS_AUTO_CHANGING(e) (changing_element[e].base_element != EL_UNDEFINED) - -#ifdef DEBUG -#if 0 -static unsigned int getStateCheckSum(int counter) -{ - int x, y; - unsigned int mult = 1; - unsigned int checksum = 0; - /* - static short lastFeld[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; - */ - static boolean first_game = TRUE; - - for (y=0; yjx, jy = player->jy; player->present = TRUE; @@ -412,15 +322,15 @@ static void InitField(int x, int y, boolean init_game) case EL_STONEBLOCK: if (x < lev_fieldx-1 && Feld[x+1][y] == EL_ACID) - Feld[x][y] = EL_ACIDPOOL_TOPLEFT; + Feld[x][y] = EL_ACID_POOL_TOPLEFT; else if (x > 0 && Feld[x-1][y] == EL_ACID) - Feld[x][y] = EL_ACIDPOOL_TOPRIGHT; - else if (y > 0 && Feld[x][y-1] == EL_ACIDPOOL_TOPLEFT) - Feld[x][y] = EL_ACIDPOOL_BOTTOMLEFT; + Feld[x][y] = EL_ACID_POOL_TOPRIGHT; + else if (y > 0 && Feld[x][y-1] == EL_ACID_POOL_TOPLEFT) + Feld[x][y] = EL_ACID_POOL_BOTTOMLEFT; else if (y > 0 && Feld[x][y-1] == EL_ACID) - Feld[x][y] = EL_ACIDPOOL_BOTTOM; - else if (y > 0 && Feld[x][y-1] == EL_ACIDPOOL_TOPRIGHT) - Feld[x][y] = EL_ACIDPOOL_BOTTOMRIGHT; + Feld[x][y] = EL_ACID_POOL_BOTTOM; + else if (y > 0 && Feld[x][y-1] == EL_ACID_POOL_TOPRIGHT) + Feld[x][y] = EL_ACID_POOL_BOTTOMRIGHT; break; case EL_BUG_RIGHT: @@ -469,7 +379,7 @@ static void InitField(int x, int y, boolean init_game) case EL_AMOEBA_DROP: if (y == lev_fieldy - 1) { - Feld[x][y] = EL_AMOEBA_CREATING; + Feld[x][y] = EL_AMOEBA_GROWING; Store[x][y] = EL_AMOEBA_WET; } break; @@ -499,31 +409,31 @@ static void InitField(int x, int y, boolean init_game) Feld[x][y] = EL_EMPTY; break; - case EL_EM_KEY1_FILE: - Feld[x][y] = EL_EM_KEY1; + case EL_EM_KEY_1_FILE: + Feld[x][y] = EL_EM_KEY_1; break; - case EL_EM_KEY2_FILE: - Feld[x][y] = EL_EM_KEY2; + case EL_EM_KEY_2_FILE: + Feld[x][y] = EL_EM_KEY_2; break; - case EL_EM_KEY3_FILE: - Feld[x][y] = EL_EM_KEY3; + case EL_EM_KEY_3_FILE: + Feld[x][y] = EL_EM_KEY_3; break; - case EL_EM_KEY4_FILE: - Feld[x][y] = EL_EM_KEY4; + case EL_EM_KEY_4_FILE: + Feld[x][y] = EL_EM_KEY_4; break; - case EL_CONVEYOR_BELT1_SWITCH_LEFT: - case EL_CONVEYOR_BELT1_SWITCH_MIDDLE: - case EL_CONVEYOR_BELT1_SWITCH_RIGHT: - case EL_CONVEYOR_BELT2_SWITCH_LEFT: - case EL_CONVEYOR_BELT2_SWITCH_MIDDLE: - case EL_CONVEYOR_BELT2_SWITCH_RIGHT: - case EL_CONVEYOR_BELT3_SWITCH_LEFT: - case EL_CONVEYOR_BELT3_SWITCH_MIDDLE: - case EL_CONVEYOR_BELT3_SWITCH_RIGHT: - case EL_CONVEYOR_BELT4_SWITCH_LEFT: - case EL_CONVEYOR_BELT4_SWITCH_MIDDLE: - case EL_CONVEYOR_BELT4_SWITCH_RIGHT: + case EL_CONVEYOR_BELT_1_SWITCH_LEFT: + case EL_CONVEYOR_BELT_1_SWITCH_MIDDLE: + case EL_CONVEYOR_BELT_1_SWITCH_RIGHT: + case EL_CONVEYOR_BELT_2_SWITCH_LEFT: + case EL_CONVEYOR_BELT_2_SWITCH_MIDDLE: + case EL_CONVEYOR_BELT_2_SWITCH_RIGHT: + case EL_CONVEYOR_BELT_3_SWITCH_LEFT: + case EL_CONVEYOR_BELT_3_SWITCH_MIDDLE: + case EL_CONVEYOR_BELT_3_SWITCH_RIGHT: + case EL_CONVEYOR_BELT_4_SWITCH_LEFT: + case EL_CONVEYOR_BELT_4_SWITCH_MIDDLE: + case EL_CONVEYOR_BELT_4_SWITCH_RIGHT: if (init_game) { int belt_nr = getBeltNrFromBeltSwitchElement(Feld[x][y]); @@ -565,107 +475,16 @@ void DrawGameDoorValues() for (j=0; j<4; j++) if (stored_player[i].key[j]) DrawMiniGraphicExt(drawto, DX_KEYS + j * MINI_TILEX, DY_KEYS, - IMG_KEY1 + j); + el2edimg(EL_KEY_1 + j)); DrawText(DX + XX_EMERALDS, DY + YY_EMERALDS, - int2str(local_player->gems_still_needed, 3), FS_SMALL, FC_YELLOW); + int2str(local_player->gems_still_needed, 3), FONT_TEXT_2); DrawText(DX + XX_DYNAMITE, DY + YY_DYNAMITE, - int2str(local_player->dynamite, 3), FS_SMALL, FC_YELLOW); + int2str(local_player->dynamite, 3), FONT_TEXT_2); DrawText(DX + XX_SCORE, DY + YY_SCORE, - int2str(local_player->score, 5), FS_SMALL, FC_YELLOW); + int2str(local_player->score, 5), FONT_TEXT_2); DrawText(DX + XX_TIME, DY + YY_TIME, - int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); -} - - -/* - ============================================================================= - InitGameSound() - ----------------------------------------------------------------------------- - initialize sound effect lookup table for element actions - ============================================================================= -*/ - -void InitGameSound() -{ - int sound_effect_properties[NUM_SOUND_FILES]; - int i, j; - -#if 0 - debug_print_timestamp(0, NULL); -#endif - - /* initialize sound effect for all elements to "no sound" */ - for (i=0; i VERSION_IDENT(2,0,1)) - Properties2[EL_WALL_GROWING_ACTIVE] |= EP_BIT_EM_SLIPPERY_WALL; - else - Properties2[EL_WALL_GROWING_ACTIVE] &=~EP_BIT_EM_SLIPPERY_WALL; + /* "EL_EXPANDABLE_WALL_GROWING" wasn't slippery for EM gems in 2.0.1 */ + 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 */ @@ -795,7 +608,7 @@ void InitGame() struct PlayerInfo *player = &stored_player[i]; player->index_nr = i; - player->element_nr = EL_PLAYER1 + i; + player->element_nr = EL_PLAYER_1 + i; player->present = FALSE; player->active = FALSE; @@ -824,15 +637,24 @@ void InitGame() player->Pushing = FALSE; player->Switching = FALSE; player->GfxPos = 0; + player->GfxDir = MV_NO_MOVING; + player->GfxAction = ACTION_DEFAULT; player->Frame = 0; + player->StepFrame = 0; - player->actual_frame_counter = 0; + player->use_murphy_graphic = FALSE; + player->use_disk_red_graphic = FALSE; - player->frame_reset_delay = 0; + player->actual_frame_counter = 0; player->last_move_dir = MV_NO_MOVING; player->is_moving = FALSE; + player->is_moving = FALSE; + player->is_waiting = FALSE; + player->is_digging = FALSE; + player->is_collecting = FALSE; + player->move_delay = game.initial_move_delay; player->move_delay_value = game.initial_move_delay_value; @@ -909,7 +731,9 @@ void InitGame() ExplodeField[x][y] = EX_NO_EXPLOSION; GfxFrame[x][y] = 0; - GfxAction[x][y] = GFX_ACTION_DEFAULT; + GfxAction[x][y] = ACTION_DEFAULT; + GfxRandom[x][y] = INIT_GFX_RANDOM(); + GfxElement[x][y] = EL_UNDEFINED; } } @@ -1081,19 +905,19 @@ void InitGame() FadeToFront(); /* copy default game door content to main double buffer */ - BlitBitmap(new_graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto, + BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto, DOOR_GFX_PAGEX5, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY); if (level_nr < 100) - DrawText(DX + XX_LEVEL, DY + YY_LEVEL, - int2str(level_nr, 2), FS_SMALL, FC_YELLOW); + DrawText(DX + XX_LEVEL, DY + YY_LEVEL, int2str(level_nr, 2), FONT_TEXT_2); else { DrawTextExt(drawto, DX + XX_EMERALDS, DY + YY_EMERALDS, - int2str(level_nr, 3), FS_SMALL, FC_SPECIAL3, FONT_OPAQUE); + int2str(level_nr, 3), FONT_LEVEL_NUMBER, BLIT_OPAQUE); BlitBitmap(drawto, drawto, DX + XX_EMERALDS, DY + YY_EMERALDS + 1, - FONT5_XSIZE * 3, FONT5_YSIZE - 1, + getFontWidth(FONT_LEVEL_NUMBER) * 3, + getFontHeight(FONT_LEVEL_NUMBER) - 1, DX + XX_LEVEL - 1, DY + YY_LEVEL + 1); } @@ -1113,7 +937,7 @@ void InitGame() OpenDoor(DOOR_OPEN_ALL); - PlaySoundStereo(SND_GAME_STARTING, SOUND_MAX_RIGHT); + PlaySoundStereo(SND_GAME_STARTING, SOUND_MIDDLE); if (setup.sound_music) PlayMusic(level_nr); @@ -1269,25 +1093,25 @@ void GameWon() local_player->LevelSolved = FALSE; - PlaySoundStereo(SND_GAME_WINNING, SOUND_MAX_RIGHT); + PlaySoundStereo(SND_GAME_WINNING, SOUND_MIDDLE); if (TimeLeft) { if (!tape.playing && setup.sound_loops) - PlaySoundExt(SND_GAME_LEVELTIME_BONUS, SOUND_MAX_VOLUME, SOUND_MAX_RIGHT, + PlaySoundExt(SND_GAME_LEVELTIME_BONUS, SOUND_MAX_VOLUME, SOUND_MIDDLE, SND_CTRL_PLAY_LOOP); while (TimeLeft > 0) { if (!tape.playing && !setup.sound_loops) - PlaySoundStereo(SND_GAME_LEVELTIME_BONUS, SOUND_MAX_RIGHT); + 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 TimeLeft--; - DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); + DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FONT_TEXT_2); BackToFront(); if (!tape.playing) @@ -1300,20 +1124,20 @@ void GameWon() else if (level.time == 0) /* level without time limit */ { if (!tape.playing && setup.sound_loops) - PlaySoundExt(SND_GAME_LEVELTIME_BONUS, SOUND_MAX_VOLUME, SOUND_MAX_RIGHT, + PlaySoundExt(SND_GAME_LEVELTIME_BONUS, SOUND_MAX_VOLUME, SOUND_MIDDLE, SND_CTRL_PLAY_LOOP); while (TimePlayed < 999) { if (!tape.playing && !setup.sound_loops) - PlaySoundStereo(SND_GAME_LEVELTIME_BONUS, SOUND_MAX_RIGHT); + 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 TimePlayed++; - DrawText(DX_TIME, DY_TIME, int2str(TimePlayed, 3), FS_SMALL, FC_YELLOW); + DrawText(DX_TIME, DY_TIME, int2str(TimePlayed, 3), FONT_TEXT_2); BackToFront(); if (!tape.playing) @@ -1324,10 +1148,6 @@ void GameWon() StopSound(SND_GAME_LEVELTIME_BONUS); } -#if 0 - FadeSounds(); -#endif - /* Hero disappears */ DrawLevelField(ExitX, ExitY); BackToFront(); @@ -1438,6 +1258,33 @@ int NewHiScore() return position; } +void InitPlayerGfxAnimation(struct PlayerInfo *player, int action, int dir) +{ + if (player->GfxAction != action || player->GfxDir != dir) + { +#if 0 + printf("Player frame reset! (%d => %d, %d => %d)\n", + player->GfxAction, action, player->GfxDir, dir); +#endif + + player->GfxAction = action; + player->GfxDir = dir; + player->Frame = 0; + player->StepFrame = 0; + } +} + +static void ResetRandomAnimationValue(int x, int y) +{ + GfxRandom[x][y] = INIT_GFX_RANDOM(); +} + +static void ResetGfxAnimation(int x, int y) +{ + GfxFrame[x][y] = 0; + GfxAction[x][y] = ACTION_DEFAULT; +} + void InitMovingField(int x, int y, int direction) { int element = Feld[x][y]; @@ -1445,18 +1292,21 @@ void InitMovingField(int x, int y, int direction) int newy = y + (direction == MV_UP ? -1 : direction == MV_DOWN ? +1 : 0); if (!JustStopped[x][y] || direction != MovDir[x][y]) - GfxFrame[x][y] = 0; + ResetGfxAnimation(x, y); - MovDir[x][y] = direction; - MovDir[newx][newy] = direction; + MovDir[newx][newy] = MovDir[x][y] = direction; if (Feld[newx][newy] == EL_EMPTY) Feld[newx][newy] = EL_BLOCKED; if (direction == MV_DOWN && CAN_FALL(element)) - GfxAction[x][y] = GFX_ACTION_FALLING; + GfxAction[x][y] = ACTION_FALLING; else - GfxAction[x][y] = GFX_ACTION_MOVING; + GfxAction[x][y] = ACTION_MOVING; + + GfxFrame[newx][newy] = GfxFrame[x][y]; + GfxAction[newx][newy] = GfxAction[x][y]; + GfxRandom[newx][newy] = GfxRandom[x][y]; } void Moving2Blocked(int x, int y, int *goes_to_x, int *goes_to_y) @@ -1528,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_EMPTY; MovPos[x][y] = 0; MovDir[x][y] = 0; MovDelay[x][y] = 0; @@ -1557,7 +1408,7 @@ void RemoveMovingField(int x, int y) (Feld[oldx][oldy] == EL_QUICKSAND_EMPTYING || Feld[oldx][oldy] == EL_MAGIC_WALL_EMPTYING || Feld[oldx][oldy] == EL_BD_MAGIC_WALL_EMPTYING || - Feld[oldx][oldy] == EL_AMOEBA_DRIPPING)) + Feld[oldx][oldy] == EL_AMOEBA_DROPPING)) Feld[oldx][oldy] = get_next_element(Feld[oldx][oldy]); else Feld[oldx][oldy] = EL_EMPTY; @@ -1567,7 +1418,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; + GfxAction[oldx][oldy] = GfxAction[newx][newy] = ACTION_DEFAULT; DrawLevelField(oldx, oldy); DrawLevelField(newx, newy); @@ -1587,37 +1438,45 @@ void DrawDynamite(int x, int y) frame = getGraphicAnimationFrame(graphic, GfxFrame[x][y]); +#if 1 + if (Store[x][y]) + DrawGraphicThruMask(sx, sy, graphic, frame); + else + DrawGraphic(sx, sy, graphic, frame); +#else if (game.emulation == EMU_SUPAPLEX) DrawGraphic(sx, sy, IMG_SP_DISK_RED, frame); else if (Store[x][y]) DrawGraphicThruMask(sx, sy, graphic, frame); else DrawGraphic(sx, sy, graphic, frame); +#endif } void CheckDynamite(int x, int y) { - int element = Feld[x][y]; - if (MovDelay[x][y] != 0) /* dynamite is still waiting to explode */ { MovDelay[x][y]--; if (MovDelay[x][y] != 0) { - if (checkDrawLevelGraphicAnimation(x, y, el2img(element))) - DrawDynamite(x, y); - - PlaySoundLevelAction(x, y, SND_ACTION_ACTIVE); + DrawDynamite(x, y); + PlaySoundLevelActionIfLoop(x, y, ACTION_ACTIVE); return; } } - if (Feld[x][y] == EL_DYNAMITE_ACTIVE) +#if 1 + StopSoundLevelActionIfLoop(x, y, ACTION_ACTIVE); +#else + if (Feld[x][y] == EL_DYNAMITE_ACTIVE || + Feld[x][y] == EL_SP_DISK_RED_ACTIVE) StopSound(SND_DYNAMITE_ACTIVE); else StopSound(SND_DYNABOMB_ACTIVE); +#endif Bang(x, y); } @@ -1666,7 +1525,7 @@ void Explode(int ex, int ey, int phase, int mode) RemoveMovingField(x, y); } - if (IS_MASSIVE(element) || element == EL_FLAMES) + if (IS_INDESTRUCTIBLE(element) || element == EL_FLAMES) continue; if (IS_PLAYER(x, y) && SHIELD_ON(PLAYERINFO(x, y))) @@ -1688,16 +1547,16 @@ void Explode(int ex, int ey, int phase, int mode) { switch(StorePlayer[ex][ey]) { - case EL_PLAYER2: + case EL_PLAYER_2: Store[x][y] = EL_EMERALD_RED; break; - case EL_PLAYER3: + case EL_PLAYER_3: Store[x][y] = EL_EMERALD; break; - case EL_PLAYER4: + case EL_PLAYER_4: Store[x][y] = EL_EMERALD_PURPLE; break; - case EL_PLAYER1: + case EL_PLAYER_1: default: Store[x][y] = EL_EMERALD_YELLOW; break; @@ -1746,13 +1605,14 @@ void Explode(int ex, int ey, int phase, int mode) if (AmoebaNr[x][y] && (element == EL_AMOEBA_FULL || element == EL_BD_AMOEBA || - element == EL_AMOEBA_CREATING)) + element == EL_AMOEBA_GROWING)) { AmoebaCnt[AmoebaNr[x][y]]--; AmoebaCnt2[AmoebaNr[x][y]]--; } Feld[x][y] = EL_EXPLOSION; + GfxElement[x][y] = EL_EMPTY; MovDir[x][y] = MovPos[x][y] = 0; AmoebaNr[x][y] = 0; ExplodePhase[x][y] = 1; @@ -1824,7 +1684,7 @@ 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 (IS_PFORTE(Store[x][y])) { @@ -1852,7 +1712,7 @@ void DynaExplode(int ex, int ey) if (IS_ACTIVE_BOMB(Feld[ex][ey])) { - player = &stored_player[Feld[ex][ey] - EL_DYNABOMB_PLAYER1_ACTIVE]; + player = &stored_player[Feld[ex][ey] - EL_DYNABOMB_PLAYER_1_ACTIVE]; dynabomb_size = player->dynabomb_size; dynabomb_xl = player->dynabomb_xl; player->dynabombs_left++; @@ -1868,7 +1728,7 @@ void DynaExplode(int ex, int ey) int y = ey + j * xy[i % 4][1]; int element; - if (!IN_LEV_FIELD(x, y) || IS_MASSIVE(Feld[x][y])) + if (!IN_LEV_FIELD(x, y) || IS_INDESTRUCTIBLE(Feld[x][y])) break; element = Feld[x][y]; @@ -1916,13 +1776,13 @@ void Bang(int x, int y) RaiseScoreElement(element); Explode(x, y, EX_PHASE_START, EX_NORMAL); break; - case EL_DYNABOMB_PLAYER1_ACTIVE: - case EL_DYNABOMB_PLAYER2_ACTIVE: - case EL_DYNABOMB_PLAYER3_ACTIVE: - case EL_DYNABOMB_PLAYER4_ACTIVE: - case EL_DYNABOMB_NR: - case EL_DYNABOMB_SZ: - case EL_DYNABOMB_XL: + case EL_DYNABOMB_PLAYER_1_ACTIVE: + case EL_DYNABOMB_PLAYER_2_ACTIVE: + case EL_DYNABOMB_PLAYER_3_ACTIVE: + case EL_DYNABOMB_PLAYER_4_ACTIVE: + case EL_DYNABOMB_INCREASE_NUMBER: + case EL_DYNABOMB_INCREASE_SIZE: + case EL_DYNABOMB_INCREASE_POWER: DynaExplode(x, y); break; case EL_PENGUIN: @@ -1939,52 +1799,24 @@ void Bang(int x, int y) } } -void Blurb(int x, int y) +void SplashAcid(int x, int y) { int element = Feld[x][y]; if (element != EL_ACID_SPLASH_LEFT && - element != EL_ACID_SPLASH_RIGHT) /* start */ + element != EL_ACID_SPLASH_RIGHT) { 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_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_SPLASH_RIGHT; - } - } - else /* go on */ - { - 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; - - if (MovDelay[x][y]) /* continue animation */ - { - MovDelay[x][y]--; - if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - { - int frame = getGraphicAnimationFrame(graphic, 8 - MovDelay[x][y]); - - DrawGraphic(SCREENX(x), SCREENY(y), graphic, frame); - } - - if (!MovDelay[x][y]) - { - Feld[x][y] = EL_EMPTY; - DrawLevelField(x, y); - } - } } } @@ -1992,17 +1824,17 @@ static void InitBeltMovement() { static int belt_base_element[4] = { - EL_CONVEYOR_BELT1_LEFT, - EL_CONVEYOR_BELT2_LEFT, - EL_CONVEYOR_BELT3_LEFT, - EL_CONVEYOR_BELT4_LEFT + EL_CONVEYOR_BELT_1_LEFT, + EL_CONVEYOR_BELT_2_LEFT, + EL_CONVEYOR_BELT_3_LEFT, + EL_CONVEYOR_BELT_4_LEFT }; static int belt_base_active_element[4] = { - EL_CONVEYOR_BELT1_LEFT_ACTIVE, - EL_CONVEYOR_BELT2_LEFT_ACTIVE, - EL_CONVEYOR_BELT3_LEFT_ACTIVE, - EL_CONVEYOR_BELT4_LEFT_ACTIVE + EL_CONVEYOR_BELT_1_LEFT_ACTIVE, + EL_CONVEYOR_BELT_2_LEFT_ACTIVE, + EL_CONVEYOR_BELT_3_LEFT_ACTIVE, + EL_CONVEYOR_BELT_4_LEFT_ACTIVE }; int x, y, i, j; @@ -2018,9 +1850,9 @@ static void InitBeltMovement() int graphic = el2img(element); if (game.belt_dir[i] == MV_LEFT) - new_graphic_info[graphic].anim_mode &= ~ANIM_REVERSE; + graphic_info[graphic].anim_mode &= ~ANIM_REVERSE; else - new_graphic_info[graphic].anim_mode |= ANIM_REVERSE; + graphic_info[graphic].anim_mode |= ANIM_REVERSE; } } @@ -2053,24 +1885,24 @@ static void ToggleBeltSwitch(int x, int y) { static int belt_base_element[4] = { - EL_CONVEYOR_BELT1_LEFT, - EL_CONVEYOR_BELT2_LEFT, - EL_CONVEYOR_BELT3_LEFT, - EL_CONVEYOR_BELT4_LEFT + EL_CONVEYOR_BELT_1_LEFT, + EL_CONVEYOR_BELT_2_LEFT, + EL_CONVEYOR_BELT_3_LEFT, + EL_CONVEYOR_BELT_4_LEFT }; static int belt_base_active_element[4] = { - EL_CONVEYOR_BELT1_LEFT_ACTIVE, - EL_CONVEYOR_BELT2_LEFT_ACTIVE, - EL_CONVEYOR_BELT3_LEFT_ACTIVE, - EL_CONVEYOR_BELT4_LEFT_ACTIVE + EL_CONVEYOR_BELT_1_LEFT_ACTIVE, + EL_CONVEYOR_BELT_2_LEFT_ACTIVE, + EL_CONVEYOR_BELT_3_LEFT_ACTIVE, + EL_CONVEYOR_BELT_4_LEFT_ACTIVE }; static int belt_base_switch_element[4] = { - EL_CONVEYOR_BELT1_SWITCH_LEFT, - EL_CONVEYOR_BELT2_SWITCH_LEFT, - EL_CONVEYOR_BELT3_SWITCH_LEFT, - EL_CONVEYOR_BELT4_SWITCH_LEFT + EL_CONVEYOR_BELT_1_SWITCH_LEFT, + EL_CONVEYOR_BELT_2_SWITCH_LEFT, + EL_CONVEYOR_BELT_3_SWITCH_LEFT, + EL_CONVEYOR_BELT_4_SWITCH_LEFT }; static int belt_move_dir[4] = { @@ -2102,9 +1934,9 @@ static void ToggleBeltSwitch(int x, int y) int graphic = el2img(element); if (belt_dir == MV_LEFT) - new_graphic_info[graphic].anim_mode &= ~ANIM_REVERSE; + graphic_info[graphic].anim_mode &= ~ANIM_REVERSE; else - new_graphic_info[graphic].anim_mode |= ANIM_REVERSE; + graphic_info[graphic].anim_mode |= ANIM_REVERSE; } for (yy=0; yy %d\n", MovDir[x][y]); -#endif TurnRound(x, y); -#if 0 - if (element == EL_SPRING) - printf("2--> %d\n", MovDir[x][y]); -#endif + if (MovDelay[x][y] && (element == EL_BUG || element == EL_SPACESHIP || element == EL_SP_SNIKSNAK || @@ -3174,36 +3045,24 @@ void StartMoving(int x, int y) MovDelay[x][y]--; if (element == EL_ROBOT || - element == EL_YAMYAM || element == EL_DARK_YAMYAM) + element == EL_YAMYAM || + element == EL_DARK_YAMYAM) { - if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - { - 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) - { - if (element == EL_YAMYAM) - PlaySoundLevel(x, y, SND_YAMYAM_WAITING); - else if (element == EL_DARK_YAMYAM) - PlaySoundLevel(x, y, SND_DARK_YAMYAM_WAITING); - } + DrawLevelElementAnimationIfNeeded(x, y, element); + PlaySoundLevelAction(x, y, ACTION_WAITING); } else if (element == EL_SP_ELECTRON) - DrawLevelElementAnimation(x, y, element); + DrawLevelElementAnimationIfNeeded(x, y, element); 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 ? IMG_FLAMES_LEFT1 : - dir == MV_RIGHT ? IMG_FLAMES_RIGHT1 : - dir == MV_UP ? IMG_FLAMES_UP1 : - dir == MV_DOWN ? IMG_FLAMES_DOWN1 : IMG_EMPTY); + int graphic = (dir == MV_LEFT ? IMG_FLAMES_1_LEFT : + dir == MV_RIGHT ? IMG_FLAMES_1_RIGHT : + dir == MV_UP ? IMG_FLAMES_1_UP : + dir == MV_DOWN ? IMG_FLAMES_1_DOWN : IMG_EMPTY); int frame = getGraphicAnimationFrame(graphic, -1); for (i=1; i<=3; i++) @@ -3240,7 +3099,7 @@ void StartMoving(int x, int y) if (MovDelay[x][y]) /* element still has to wait some time */ { - PlaySoundLevelAction(x, y, SND_ACTION_WAITING); + PlaySoundLevelAction(x, y, ACTION_WAITING); return; } @@ -3270,7 +3129,7 @@ void StartMoving(int x, int y) IN_LEV_FIELD(newx, newy) && MovDir[x][y] == MV_DOWN && Feld[newx][newy] == EL_ACID) { - Blurb(x, y); + SplashAcid(x, y); Store[x][y] = EL_ACID; } else if (element == EL_PENGUIN && IN_LEV_FIELD(newx, newy)) @@ -3280,7 +3139,7 @@ void StartMoving(int x, int y) Feld[x][y] = EL_EMPTY; DrawLevelField(x, y); - PlaySoundLevel(newx, newy, SND_PENGUIN_PASSING_EXIT); + PlaySoundLevel(newx, newy, SND_PENGUIN_PASSING); if (IN_SCR_FIELD(SCREENX(newx), SCREENY(newy))) DrawGraphicThruMask(SCREENX(newx),SCREENY(newy), el2img(element), 0); @@ -3291,7 +3150,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); @@ -3319,7 +3178,7 @@ void StartMoving(int x, int y) DrawLevelField(newx, newy); } - PlaySoundLevel(x, y, SND_PIG_EATING); + PlaySoundLevel(x, y, SND_PIG_DIGGING); } else if (!IS_FREE(newx, newy)) { @@ -3383,10 +3242,10 @@ void StartMoving(int x, int y) DrawLevelField(newx, newy); } - PlaySoundLevel(x, y, SND_YAMYAM_EATING); + 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]) { @@ -3404,7 +3263,7 @@ void StartMoving(int x, int y) DrawLevelField(newx, newy); } - PlaySoundLevel(x, y, SND_DARK_YAMYAM_EATING); + PlaySoundLevel(x, y, SND_DARK_YAMYAM_DIGGING); } else if ((element == EL_PACMAN || element == EL_MOLE) && IN_LEV_FIELD(newx, newy) && IS_AMOEBOID(Feld[newx][newy])) @@ -3420,7 +3279,7 @@ void StartMoving(int x, int y) if (element == EL_MOLE) { Feld[newx][newy] = EL_AMOEBA_SHRINKING; - PlaySoundLevel(x, y, SND_MOLE_EATING); + PlaySoundLevel(x, y, SND_MOLE_DIGGING); MovDelay[newx][newy] = 0; /* start amoeba shrinking delay */ return; /* wait for shrinking amoeba */ } @@ -3428,7 +3287,7 @@ void StartMoving(int x, int y) { Feld[newx][newy] = EL_EMPTY; DrawLevelField(newx, newy); - PlaySoundLevel(x, y, SND_PACMAN_EATING); + PlaySoundLevel(x, y, SND_PACMAN_DIGGING); } } else if (element == EL_MOLE && IN_LEV_FIELD(newx, newy) && @@ -3451,23 +3310,23 @@ 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) - DrawLevelElementAnimation(x, y, element); + DrawLevelElementAnimationIfNeeded(x, y, element); else if (element == EL_SATELLITE) - DrawLevelElementAnimation(x, y, element); + DrawLevelElementAnimationIfNeeded(x, y, element); else if (element == EL_SP_ELECTRON) - DrawLevelElementAnimation(x, y, element); + DrawLevelElementAnimationIfNeeded(x, y, element); if (DONT_TOUCH(element)) TestIfBadThingTouchesHero(x, y); - PlaySoundLevelAction(x, y, SND_ACTION_WAITING); + PlaySoundLevelAction(x, y, ACTION_WAITING); return; } InitMovingField(x, y, MovDir[x][y]); - PlaySoundLevelAction(x, y, SND_ACTION_MOVING); + PlaySoundLevelAction(x, y, ACTION_MOVING); } if (MovDir[x][y]) @@ -3484,7 +3343,7 @@ void ContinueMoving(int x, int y) int newx = x + dx, newy = y + dy; int step = (horiz_move ? dx : dy) * TILEX / 8; - if (element == EL_AMOEBA_DROP || element == EL_AMOEBA_DRIPPING) + if (element == EL_AMOEBA_DROP || element == EL_AMOEBA_DROPPING) step /= 2; else if (element == EL_QUICKSAND_FILLING || element == EL_QUICKSAND_EMPTYING) @@ -3534,7 +3393,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" */ } } @@ -3576,7 +3435,7 @@ void ContinueMoving(int x, int y) Feld[x][y] = EL_BD_MAGIC_WALL_DEAD; element = Feld[newx][newy] = Store[x][y]; } - else if (element == EL_AMOEBA_DRIPPING) + else if (element == EL_AMOEBA_DROPPING) { Feld[x][y] = get_next_element(element); element = Feld[newx][newy] = Store[x][y]; @@ -3590,9 +3449,14 @@ void ContinueMoving(int x, int y) MovPos[x][y] = MovDir[x][y] = MovDelay[x][y] = 0; MovDelay[newx][newy] = 0; + /* copy animation control values to new field */ + GfxFrame[newx][newy] = GfxFrame[x][y]; GfxAction[newx][newy] = GfxAction[x][y]; /* keep action one frame */ - GfxAction[x][y] = GFX_ACTION_DEFAULT; + GfxRandom[newx][newy] = GfxRandom[x][y]; /* keep same random value */ + ResetGfxAnimation(x, y); /* reset animation values for old field */ + +#if 1 #if 0 if (!CAN_MOVE(element)) MovDir[newx][newy] = 0; @@ -3605,6 +3469,7 @@ void ContinueMoving(int x, int y) if (!CAN_MOVE(element) || (element == EL_SPRING && MovDir[newx][newy] == MV_DOWN)) MovDir[newx][newy] = 0; +#endif #endif DrawLevelField(x, y); @@ -3628,15 +3493,6 @@ void ContinueMoving(int x, int y) } else /* still moving on */ { -#if 0 - if (GfxAction[x][y] == GFX_ACTION_DEFAULT) - { - printf("reset GfxAction...\n"); - - GfxAction[x][y] = GFX_ACTION_MOVING; - } -#endif - DrawLevelField(x, y); } } @@ -3803,7 +3659,7 @@ void AmoebeUmwandelnBD(int ax, int ay, int new_element) if (AmoebaNr[x][y] == group_nr && (Feld[x][y] == EL_AMOEBA_DEAD || Feld[x][y] == EL_BD_AMOEBA || - Feld[x][y] == EL_AMOEBA_CREATING)) + Feld[x][y] == EL_AMOEBA_GROWING)) { AmoebaNr[x][y] = 0; Feld[x][y] = new_element; @@ -3831,10 +3687,14 @@ void AmoebeWaechst(int x, int y) if (DelayReached(&sound_delay, sound_delay_value)) { +#if 1 + PlaySoundLevelElementAction(x, y, Store[x][y], ACTION_GROWING); +#else if (Store[x][y] == EL_BD_AMOEBA) - PlaySoundLevel(x, y, SND_BD_AMOEBA_CREATING); + PlaySoundLevel(x, y, SND_BD_AMOEBA_GROWING); else - PlaySoundLevel(x, y, SND_AMOEBA_CREATING); + PlaySoundLevel(x, y, SND_AMOEBA_GROWING); +#endif sound_delay_value = 30; } } @@ -3844,10 +3704,10 @@ void AmoebeWaechst(int x, int y) MovDelay[x][y]--; if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x), SCREENY(y))) { - int frame = getGraphicAnimationFrame(IMG_AMOEBA_CREATING, + int frame = getGraphicAnimationFrame(IMG_AMOEBA_GROWING, 6 - MovDelay[x][y]); - DrawGraphic(SCREENX(x), SCREENY(y), IMG_AMOEBA_CREATING, frame); + DrawGraphic(SCREENX(x), SCREENY(y), IMG_AMOEBA_GROWING, frame); } if (!MovDelay[x][y]) @@ -3899,6 +3759,7 @@ void AmoebeAbleger(int ax, int ay) { int i; int element = Feld[ax][ay]; + int graphic = el2img(element); int newax = ax, neway = ay; static int xy[4][2] = { @@ -3915,6 +3776,9 @@ void AmoebeAbleger(int ax, int ay) return; } + if (IS_ANIMATED(graphic)) + DrawLevelGraphicAnimationIfNeeded(ax, ay, graphic); + if (!MovDelay[ax][ay]) /* start making new amoeba field */ MovDelay[ax][ay] = RND(FRAMES_PER_SECOND * 25 / (1 + level.amoeba_speed)); @@ -4020,18 +3884,22 @@ void AmoebeAbleger(int ax, int ay) if (element != EL_AMOEBA_WET || neway < ay || !IS_FREE(newax, neway) || (neway == lev_fieldy - 1 && newax != ax)) { - Feld[newax][neway] = EL_AMOEBA_CREATING; /* creation of new amoeba */ + Feld[newax][neway] = EL_AMOEBA_GROWING; /* creation of new amoeba */ Store[newax][neway] = element; } else if (neway == ay) { Feld[newax][neway] = EL_AMOEBA_DROP; /* drop left/right of amoeba */ - PlaySoundLevel(newax, neway, SND_AMOEBA_DROP_CREATING); +#if 1 + PlaySoundLevelAction(newax, neway, ACTION_GROWING); +#else + PlaySoundLevel(newax, neway, SND_AMOEBA_GROWING); +#endif } else { InitMovingField(ax, ay, MV_DOWN); /* drop dripping from amoeba */ - Feld[ax][ay] = EL_AMOEBA_DRIPPING; + Feld[ax][ay] = EL_AMOEBA_DROPPING; Store[ax][ay] = EL_AMOEBA_DROP; ContinueMoving(ax, ay); return; @@ -4046,8 +3914,12 @@ void Life(int ax, int ay) static int life[4] = { 2, 3, 3, 3 }; /* parameters for "game of life" */ int life_time = 40; int element = Feld[ax][ay]; + int graphic = el2img(element); boolean changed = FALSE; + if (IS_ANIMATED(graphic)) + DrawLevelGraphicAnimationIfNeeded(ax, ay, graphic); + if (Stop[ax][ay]) return; @@ -4077,7 +3949,7 @@ void Life(int ax, int ay) continue; if (((Feld[x][y] == element || - (element == EL_GAMEOFLIFE && IS_PLAYER(x, y))) && + (element == EL_GAME_OF_LIFE && IS_PLAYER(x, y))) && !Stop[x][y]) || (IS_FREE(x, y) && Stop[x][y])) nachbarn++; @@ -4099,7 +3971,7 @@ void Life(int ax, int ay) if (nachbarn >= life[2] && nachbarn <= life[3]) { Feld[xx][yy] = element; - MovDelay[xx][yy] = (element == EL_GAMEOFLIFE ? 0 : life_time-1); + MovDelay[xx][yy] = (element == EL_GAME_OF_LIFE ? 0 : life_time-1); if (!Stop[xx][yy]) DrawLevelField(xx, yy); Stop[xx][yy] = TRUE; @@ -4109,8 +3981,8 @@ void Life(int ax, int ay) } if (changed) - PlaySoundLevel(ax, ay, element == EL_GAMEOFLIFE ? SND_GAMEOFLIFE_CREATING : - SND_BIOMAZE_CREATING); + PlaySoundLevel(ax, ay, element == EL_BIOMAZE ? SND_BIOMAZE_GROWING : + SND_GAME_OF_LIFE_GROWING); } static void InitRobotWheel(int x, int y) @@ -4129,38 +4001,6 @@ static void StopRobotWheel(int x, int y) ZX = ZY = -1; } -#if 1 -void RobotWheel(int x, int y) -{ - if (!MovDelay[x][y]) /* next animation frame */ - MovDelay[x][y] = level.time_wheel * FRAMES_PER_SECOND; - - if (MovDelay[x][y]) /* wait some time before next frame */ - { - MovDelay[x][y]--; - if (MovDelay[x][y]) - { - if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - { - int frame = getGraphicAnimationFrame(IMG_ROBOT_WHEEL_ACTIVE, -1); - - DrawGraphic(SCREENX(x), SCREENY(y), IMG_ROBOT_WHEEL_ACTIVE, frame); - } - - 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; -} -#endif - static void InitTimegateWheel(int x, int y) { MovDelay[x][y] = level.time_wheel * FRAMES_PER_SECOND; @@ -4171,290 +4011,43 @@ static void RunTimegateWheel(int x, int y) PlaySoundLevel(x, y, SND_TIMEGATE_SWITCH_ACTIVE); } -#if 1 -void TimegateWheel(int x, int y) +void CheckExit(int x, int y) { - if (!MovDelay[x][y]) /* next animation frame */ - MovDelay[x][y] = level.time_wheel * FRAMES_PER_SECOND; - - if (MovDelay[x][y]) /* wait some time before next frame */ + if (local_player->gems_still_needed > 0 || + local_player->sokobanfields_still_needed > 0 || + local_player->lights_still_needed > 0) { - MovDelay[x][y]--; - if (MovDelay[x][y]) - { - if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - { - int frame = getGraphicAnimationFrame(IMG_TIMEGATE_SWITCH_ACTIVE, -1); - - DrawGraphic(SCREENX(x), SCREENY(y), IMG_TIMEGATE_SWITCH_ACTIVE, frame); - } + int element = Feld[x][y]; + int graphic = el2img(element); - PlaySoundLevel(x, y, SND_TIMEGATE_SWITCH_ACTIVE); + if (IS_ANIMATED(graphic)) + DrawLevelGraphicAnimationIfNeeded(x, y, graphic); - return; - } + return; } - Feld[x][y] = EL_TIMEGATE_SWITCH; - DrawLevelField(x, y); + Feld[x][y] = EL_EXIT_OPENING; - /* THIS HAS NO EFFECT AT ALL! */ -#if 1 - /* !!! THIS LOOKS WRONG !!! */ - if (ZX == x && ZY == y) - ZX = ZY = -1; -#endif - -} -#endif - -#if 1 -void NussKnacken(int x, int y) -{ - if (!MovDelay[x][y]) /* next animation frame */ - MovDelay[x][y] = 7; - - if (MovDelay[x][y]) /* wait some time before next frame */ - { - MovDelay[x][y]--; - if (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); - } - - return; - } - } - - Feld[x][y] = EL_EMERALD; - DrawLevelField(x, y); -} -#endif - -#if 1 -void BreakingPearl(int x, int y) -{ - if (!MovDelay[x][y]) /* next animation frame */ - MovDelay[x][y] = 9; - - if (MovDelay[x][y]) /* wait some time before next frame */ - { - MovDelay[x][y]--; - if (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); - } - - return; - } - } - - Feld[x][y] = EL_EMPTY; - DrawLevelField(x, y); -} -#endif - -void SiebAktivieren(int x, int y, int type) -{ - int graphic = (type == 1 ? IMG_MAGIC_WALL_FULL : IMG_BD_MAGIC_WALL_FULL); - - DrawLevelGraphicAnimation(x, y, graphic); -} - -void CheckExit(int x, int y) -{ - if (local_player->gems_still_needed > 0 || - local_player->sokobanfields_still_needed > 0 || - local_player->lights_still_needed > 0) - return; - - Feld[x][y] = EL_EXIT_OPENING; - - PlaySoundLevelNearest(x, y, SND_EXIT_OPENING); + PlaySoundLevelNearest(x, y, SND_CLASS_EXIT_OPENING); } void CheckExitSP(int x, int y) { if (local_player->gems_still_needed > 0) - return; - - Feld[x][y] = EL_SP_EXIT_OPEN; - - PlaySoundLevelNearest(x, y, SND_SP_EXIT_OPENING); -} - -#if 1 -void AusgangstuerOeffnen(int x, int y) -{ - int delay = 6; - - if (!MovDelay[x][y]) /* next animation frame */ - MovDelay[x][y] = 5 * delay; - - if (MovDelay[x][y]) /* wait some time before next frame */ { - int tuer; - - MovDelay[x][y]--; - tuer = MovDelay[x][y] / delay; - - if (!(MovDelay[x][y] % delay)) - { - 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); - } - } - - if (MovDelay[x][y]) - return; - } - - Feld[x][y] = EL_EXIT_OPEN; - DrawLevelField(x, y); -} -#endif - -#if 1 -void OpenSwitchgate(int x, int y) -{ - int delay = 6; - - if (!MovDelay[x][y]) /* next animation frame */ - MovDelay[x][y] = 5 * delay; - - if (MovDelay[x][y]) /* wait some time before next frame */ - { - MovDelay[x][y]--; - - if (!(MovDelay[x][y] % delay)) - { - 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); - } - } - - if (MovDelay[x][y]) - return; - } - - Feld[x][y] = EL_SWITCHGATE_OPEN; - DrawLevelField(x, y); -} -#endif - -#if 1 -void CloseSwitchgate(int x, int y) -{ - int delay = 6; - - if (!MovDelay[x][y]) /* next animation frame */ - MovDelay[x][y] = 5 * delay; - - if (MovDelay[x][y]) /* wait some time before next frame */ - { - MovDelay[x][y]--; - - if (!(MovDelay[x][y] % delay)) - { - 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); - } - } - - if (MovDelay[x][y]) - return; - } - - Feld[x][y] = EL_SWITCHGATE_CLOSED; - DrawLevelField(x, y); -} -#endif - -#if 1 -void OpenTimegate(int x, int y) -{ - int delay = 6; - - if (!MovDelay[x][y]) /* next animation frame */ - MovDelay[x][y] = 5 * delay; - - if (MovDelay[x][y]) /* wait some time before next frame */ - { - MovDelay[x][y]--; - - if (!(MovDelay[x][y] % delay)) - { - if (IN_SCR_FIELD(SCREENX(x), SCREENY(y))) - { - int frame = getGraphicAnimationFrame(IMG_TIMEGATE_OPENING, - 29 - MovDelay[x][y]); + int element = Feld[x][y]; + int graphic = el2img(element); - DrawGraphic(SCREENX(x), SCREENY(y), IMG_TIMEGATE_OPENING, frame); - } - } + if (IS_ANIMATED(graphic)) + DrawLevelGraphicAnimationIfNeeded(x, y, graphic); - if (MovDelay[x][y]) - return; + return; } - Feld[x][y] = EL_TIMEGATE_OPEN; - DrawLevelField(x, y); -} -#endif - -#if 1 -void CloseTimegate(int x, int y) -{ - int delay = 6; - - if (!MovDelay[x][y]) /* next animation frame */ - MovDelay[x][y] = 5 * delay; - - if (MovDelay[x][y]) /* wait some time before next frame */ - { - MovDelay[x][y]--; - - if (!(MovDelay[x][y] % delay)) - { - 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); - } - } - - if (MovDelay[x][y]) - return; - } + Feld[x][y] = EL_SP_EXIT_OPEN; - Feld[x][y] = EL_TIMEGATE_CLOSED; - DrawLevelField(x, y); + PlaySoundLevelNearest(x, y, SND_CLASS_SP_EXIT_OPENING); } -#endif static void CloseAllOpenTimegates() { @@ -4469,7 +4062,11 @@ static void CloseAllOpenTimegates() if (element == EL_TIMEGATE_OPEN || element == EL_TIMEGATE_OPENING) { Feld[x][y] = EL_TIMEGATE_CLOSING; +#if 1 + PlaySoundLevelAction(x, y, ACTION_CLOSING); +#else PlaySoundLevel(x, y, SND_TIMEGATE_CLOSING); +#endif } } } @@ -4481,47 +4078,37 @@ void EdelsteinFunkeln(int x, int y) return; if (Feld[x][y] == EL_BD_DIAMOND) -#if 0 - DrawLevelElementAnimation(x, y, el2img(Feld[x][y])); -#else return; -#endif - else - { - if (MovDelay[x][y] == 0) /* next animation frame */ - MovDelay[x][y] = 11 * !SimpleRND(500); - if (MovDelay[x][y] != 0) /* wait some time before next frame */ - { - MovDelay[x][y]--; + if (MovDelay[x][y] == 0) /* next animation frame */ + MovDelay[x][y] = 11 * !SimpleRND(500); - if (setup.direct_draw && MovDelay[x][y]) - SetDrawtoField(DRAW_BUFFERED); + if (MovDelay[x][y] != 0) /* wait some time before next frame */ + { + MovDelay[x][y]--; -#if 0 - DrawGraphic(SCREENX(x), SCREENY(y), el2img(Feld[x][y]), 0); -#else - DrawLevelElementAnimation(x, y, Feld[x][y]); -#endif + if (setup.direct_draw && MovDelay[x][y]) + SetDrawtoField(DRAW_BUFFERED); - if (MovDelay[x][y] != 0) - { - int frame = getGraphicAnimationFrame(IMG_TWINKLE_WHITE, - 10 - MovDelay[x][y]); + DrawLevelElementAnimation(x, y, Feld[x][y]); - DrawGraphicThruMask(SCREENX(x), SCREENY(y), IMG_TWINKLE_WHITE, frame); + if (MovDelay[x][y] != 0) + { + int frame = getGraphicAnimationFrame(IMG_TWINKLE_WHITE, + 10 - MovDelay[x][y]); - if (setup.direct_draw) - { - int dest_x, dest_y; + DrawGraphicThruMask(SCREENX(x), SCREENY(y), IMG_TWINKLE_WHITE, frame); - dest_x = FX + SCREENX(x) * TILEX; - dest_y = FY + SCREENY(y) * TILEY; + if (setup.direct_draw) + { + int dest_x, dest_y; - BlitBitmap(drawto_field, window, - dest_x, dest_y, TILEX, TILEY, dest_x, dest_y); - SetDrawtoField(DRAW_DIRECT); - } + 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); + SetDrawtoField(DRAW_DIRECT); } } } @@ -4580,12 +4167,16 @@ void MauerWaechst(int x, int y) void MauerAbleger(int ax, int ay) { int element = Feld[ax][ay]; + int graphic = el2img(element); boolean oben_frei = FALSE, unten_frei = FALSE; boolean links_frei = FALSE, rechts_frei = FALSE; boolean oben_massiv = FALSE, unten_massiv = FALSE; boolean links_massiv = FALSE, rechts_massiv = FALSE; boolean new_wall = FALSE; + if (IS_ANIMATED(graphic)) + DrawLevelGraphicAnimationIfNeeded(ax, ay, graphic); + if (!MovDelay[ax][ay]) /* start building new wall */ MovDelay[ax][ay] = 6; @@ -4605,57 +4196,59 @@ void MauerAbleger(int ax, int ay) if (IN_LEV_FIELD(ax+1, ay) && IS_FREE(ax+1, ay)) rechts_frei = TRUE; - if (element == EL_WALL_GROWING_Y || element == EL_WALL_GROWING_XY) + if (element == EL_EXPANDABLE_WALL_VERTICAL || + element == EL_EXPANDABLE_WALL_ANY) { if (oben_frei) { - Feld[ax][ay-1] = EL_WALL_GROWING_ACTIVE; + Feld[ax][ay-1] = EL_EXPANDABLE_WALL_GROWING; 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), - IMG_WALL_GROWING_ACTIVE_UP, 0); + IMG_EXPANDABLE_WALL_GROWING_UP, 0); new_wall = TRUE; } if (unten_frei) { - Feld[ax][ay+1] = EL_WALL_GROWING_ACTIVE; + Feld[ax][ay+1] = EL_EXPANDABLE_WALL_GROWING; 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), - IMG_WALL_GROWING_ACTIVE_DOWN, 0); + IMG_EXPANDABLE_WALL_GROWING_DOWN, 0); new_wall = TRUE; } } - if (element == EL_WALL_GROWING_X || element == EL_WALL_GROWING_XY || - element == EL_WALL_GROWING) + if (element == EL_EXPANDABLE_WALL_HORIZONTAL || + element == EL_EXPANDABLE_WALL_ANY || + element == EL_EXPANDABLE_WALL) { if (links_frei) { - Feld[ax-1][ay] = EL_WALL_GROWING_ACTIVE; + Feld[ax-1][ay] = EL_EXPANDABLE_WALL_GROWING; 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), - IMG_WALL_GROWING_ACTIVE_LEFT, 0); + IMG_EXPANDABLE_WALL_GROWING_LEFT, 0); new_wall = TRUE; } if (rechts_frei) { - Feld[ax+1][ay] = EL_WALL_GROWING_ACTIVE; + Feld[ax+1][ay] = EL_EXPANDABLE_WALL_GROWING; 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), - IMG_WALL_GROWING_ACTIVE_RIGHT, 0); + IMG_EXPANDABLE_WALL_GROWING_RIGHT, 0); new_wall = TRUE; } } - if (element == EL_WALL_GROWING && (links_frei || rechts_frei)) + if (element == EL_EXPANDABLE_WALL && (links_frei || rechts_frei)) DrawLevelField(ax, ay); if (!IN_LEV_FIELD(ax, ay-1) || IS_MAUER(Feld[ax][ay-1])) @@ -4668,13 +4261,18 @@ void MauerAbleger(int ax, int ay) rechts_massiv = TRUE; if (((oben_massiv && unten_massiv) || - element == EL_WALL_GROWING_X || element == EL_WALL_GROWING) && + element == EL_EXPANDABLE_WALL_HORIZONTAL || + element == EL_EXPANDABLE_WALL) && ((links_massiv && rechts_massiv) || - element == EL_WALL_GROWING_Y)) + element == EL_EXPANDABLE_WALL_VERTICAL)) Feld[ax][ay] = EL_WALL; if (new_wall) - PlaySoundLevel(ax, ay, SND_WALL_GROWING); +#if 1 + PlaySoundLevelAction(ax, ay, ACTION_GROWING); +#else + PlaySoundLevel(ax, ay, SND_EXPANDABLE_WALL_GROWING); +#endif } void CheckForDragon(int x, int y) @@ -4751,176 +4349,37 @@ static void WarnBuggyBase(int x, int y) { 0, +1 } }; - for (i=0; i<4; i++) - { - int xx = x + xy[i][0], yy = y + xy[i][1]; - - if (IS_PLAYER(xx, yy)) - { - PlaySoundLevel(x, y, SND_SP_BUGGY_BASE_ACTIVE); - - break; - } - } -} - -#if 1 -void CheckBuggyBase(int x, int y) -{ - int element = Feld[x][y]; - - if (element == EL_SP_BUGGY_BASE) - { - if (MovDelay[x][y] == 0) /* wait some time before activating base */ - { - GfxFrame[x][y] = 0; - - InitBuggyBase(x, y); - } - - MovDelay[x][y]--; - - if (MovDelay[x][y] != 0) - { - DrawLevelElementAnimation(x, y, element); - } - else - { - Feld[x][y] = EL_SP_BUGGY_BASE_ACTIVATING; - DrawLevelField(x, y); - } - } - else if (element == EL_SP_BUGGY_BASE_ACTIVATING) - { - if (MovDelay[x][y] == 0) /* display activation warning of buggy base */ - { - GfxFrame[x][y] = 0; - - InitBuggyBase(x, y); - } - - MovDelay[x][y]--; - - if (MovDelay[x][y] != 0) - { - DrawLevelElementAnimation(x, y, element); - } - else - { - Feld[x][y] = EL_SP_BUGGY_BASE_ACTIVE; - DrawLevelField(x, y); - } - } - else if (element == EL_SP_BUGGY_BASE_ACTIVE) - { - if (MovDelay[x][y] == 0) /* start activating buggy base */ - { - GfxFrame[x][y] = 0; - - InitBuggyBase(x, y); - } - - MovDelay[x][y]--; - - if (MovDelay[x][y] != 0) - { - DrawLevelElementAnimation(x, y, element); - - WarnBuggyBase(x, y); - } - else - { - Feld[x][y] = EL_SP_BUGGY_BASE; - DrawLevelField(x, y); - } - } -} -#endif - -static void InitTrap(int x, int y) -{ - MovDelay[x][y] = 2 * FRAMES_PER_SECOND + RND(5 * FRAMES_PER_SECOND); -} - -static void ActivateTrap(int x, int y) -{ - PlaySoundLevel(x, y, SND_TRAP_ACTIVATING); -} - -static void ChangeActiveTrap(int x, int y) -{ - int graphic = IMG_TRAP_ACTIVE; - - /* if animation frame already drawn, correct crumbled sand border */ - if (IS_ANIMATED(graphic)) - if (checkDrawLevelGraphicAnimation(x, y, graphic)) - DrawCrumbledSand(SCREENX(x), SCREENY(y)); -} - -#if 1 -void CheckTrap(int x, int y) -{ - int element = Feld[x][y]; - - if (element == EL_TRAP) - { - if (MovDelay[x][y] == 0) /* wait some time before activating trap */ - MovDelay[x][y] = 2 * FRAMES_PER_SECOND + RND(5 * FRAMES_PER_SECOND); - - MovDelay[x][y]--; - - if (MovDelay[x][y] != 0) - { - /* do nothing while waiting */ - } - else - { - Feld[x][y] = EL_TRAP_ACTIVE; - PlaySoundLevel(x, y, SND_TRAP_ACTIVATING); - } - } - else if (element == EL_TRAP_ACTIVE) - { - int delay = 4; - int num_frames = 8; - - if (MovDelay[x][y] == 0) /* start activating trap */ - { - MovDelay[x][y] = num_frames * delay; - GfxFrame[x][y] = 0; - } - - MovDelay[x][y]--; + for (i=0; i<4; i++) + { + int xx = x + xy[i][0], yy = y + xy[i][1]; - if (MovDelay[x][y] != 0) - { - if (DrawLevelElementAnimation(x, y, element)) - DrawCrumbledSand(SCREENX(x), SCREENY(y)); - } - else + if (IS_PLAYER(xx, yy)) { - Feld[x][y] = EL_TRAP; - DrawLevelField(x, y); + PlaySoundLevel(x, y, SND_SP_BUGGY_BASE_ACTIVE); + + break; } } } -#endif -#if 1 -static void DrawBeltAnimation(int x, int y, int element) +static void InitTrap(int x, int y) { - int belt_nr = getBeltNrFromBeltActiveElement(element); - int belt_dir = game.belt_dir[belt_nr]; + MovDelay[x][y] = 2 * FRAMES_PER_SECOND + RND(5 * FRAMES_PER_SECOND); +} - if (belt_dir != MV_NO_MOVING) - { - DrawLevelElementAnimation(x, y, element); +static void ActivateTrap(int x, int y) +{ + PlaySoundLevel(x, y, SND_TRAP_ACTIVATING); +} - if (!(FrameCounter % 2)) - PlaySoundLevelAction(x, y, SND_ACTION_ACTIVE); - } +static void ChangeActiveTrap(int x, int y) +{ + int graphic = IMG_TRAP_ACTIVE; + + /* if new animation frame was drawn, correct crumbled sand border */ + if (IS_NEW_FRAME(GfxFrame[x][y], graphic)) + DrawLevelFieldCrumbledSand(x, y); } -#endif static void ChangeElement(int x, int y) { @@ -4929,7 +4388,9 @@ static void ChangeElement(int x, int y) if (MovDelay[x][y] == 0) /* initialize element change */ { MovDelay[x][y] = changing_element[element].change_delay + 1; - GfxFrame[x][y] = 0; + + ResetGfxAnimation(x, y); + ResetRandomAnimationValue(x, y); if (changing_element[element].pre_change_function) changing_element[element].pre_change_function(x, y); @@ -4940,7 +4401,7 @@ static void ChangeElement(int x, int y) if (MovDelay[x][y] != 0) /* continue element change */ { if (IS_ANIMATED(el2img(element))) - DrawLevelElementAnimation(x, y, element); + DrawLevelElementAnimationIfNeeded(x, y, element); if (changing_element[element].change_function) changing_element[element].change_function(x, y); @@ -4948,7 +4409,9 @@ static void ChangeElement(int x, int y) else /* finish element change */ { Feld[x][y] = changing_element[element].next_element; - GfxFrame[x][y] = 0; + + ResetGfxAnimation(x, y); + ResetRandomAnimationValue(x, y); DrawLevelField(x, y); @@ -4961,9 +4424,6 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) { static byte stored_player_action[MAX_PLAYERS]; static int num_stored_actions = 0; -#if 0 - static boolean save_tape_entry = FALSE; -#endif boolean moved = FALSE, snapped = FALSE, bombed = FALSE; int left = player_action & JOY_LEFT; int right = player_action & JOY_RIGHT; @@ -4982,11 +4442,6 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) if (player_action) { -#if 0 - save_tape_entry = TRUE; -#endif - player->frame_reset_delay = 0; - if (button1) snapped = SnapField(player, dx, dy); else @@ -5005,20 +4460,7 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) } } -#if 0 - if (tape.recording && (moved || snapped || bombed)) - { - if (bombed && !moved) - player_action &= JOY_BUTTON; - - stored_player_action[player->index_nr] = player_action; - save_tape_entry = TRUE; - } - else if (tape.playing && snapped) - SnapField(player, 0, 0); /* stop snapping */ -#else stored_player_action[player->index_nr] = player_action; -#endif } else { @@ -5028,81 +4470,31 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) SnapField(player, 0, 0); CheckGravityMovement(player); -#if 1 - if (player->MovPos == 0) /* needed for tape.playing */ - player->is_moving = FALSE; -#endif + if (player->MovPos == 0) + { #if 0 - if (player->MovPos == 0) /* needed for tape.playing */ - player->last_move_dir = MV_NO_MOVING; - - /* !!! CHECK THIS AGAIN !!! - (Seems to be needed for some EL_ROBOT stuff, but breaks - tapes when walking through pipes!) - */ + printf("Trying... Player frame reset\n"); +#endif - /* it seems that "player->last_move_dir" is misused as some sort of - "player->is_just_moving_in_this_moment", which is needed for the - robot stuff (robots don't kill players when they are moving) - */ -#endif + InitPlayerGfxAnimation(player, ACTION_DEFAULT, player->MovDir); + } - /* 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; + if (player->MovPos == 0) /* needed for tape.playing */ + player->is_moving = FALSE; } -#if 0 - if (tape.recording && num_stored_actions >= MAX_PLAYERS && save_tape_entry) - { - TapeRecordAction(stored_player_action); - num_stored_actions = 0; - save_tape_entry = FALSE; - } -#else if (tape.recording && num_stored_actions >= MAX_PLAYERS) { TapeRecordAction(stored_player_action); num_stored_actions = 0; } -#endif - -#if 0 - if (tape.playing && !tape.pausing && !player_action && - tape.counter < tape.length) - { - int jx = player->jx, jy = player->jy; - int next_joy = - tape.pos[tape.counter].action[player->index_nr] & (JOY_LEFT|JOY_RIGHT); - - if ((next_joy == JOY_LEFT || next_joy == JOY_RIGHT) && - (player->MovDir != JOY_UP && player->MovDir != JOY_DOWN)) - { - int dx = (next_joy == JOY_LEFT ? -1 : +1); - - if (IN_LEV_FIELD(jx+dx, jy) && IS_PUSHABLE(Feld[jx+dx][jy])) - { - int el = Feld[jx+dx][jy]; - int push_delay = (IS_SB_ELEMENT(el) || el == EL_SATELLITE ? 2 : - (el == EL_BALLOON || el == EL_SPRING) ? 0 : 10); - - if (tape.delay_played + push_delay >= tape.pos[tape.counter].delay) - { - player->MovDir = next_joy; - player->Frame = FrameCounter % 4; - player->Pushing = TRUE; - } - } - } - } -#endif } void GameActions() { static unsigned long action_delay = 0; unsigned long action_delay_value; - int sieb_x = 0, sieb_y = 0; + int magic_wall_x = 0, magic_wall_y = 0; int i, x, y, element, graphic; byte *recorded_player_action; byte summarized_player_action = 0; @@ -5186,30 +4578,14 @@ void GameActions() ScrollScreen(NULL, SCROLL_GO_ON); - - -#ifdef DEBUG -#if 0 - if (TimeFrames == 0 && local_player->active) - { - extern unsigned int last_RND(); - - printf("DEBUG: %03d last RND was %d \t [state checksum is %d]\n", - TimePlayed, last_RND(), getStateCheckSum(TimePlayed)); - } -#endif -#endif - -#ifdef DEBUG #if 0 - if (GameFrameDelay >= 500) - printf("FrameCounter == %d\n", FrameCounter); -#endif -#endif - FrameCounter++; TimeFrames++; + for (i=0; ijx, jy = local_player->jy; - if (element == EL_MAGIC_WALL_FULL || - element == EL_MAGIC_WALL_ACTIVE || - element == EL_MAGIC_WALL_EMPTYING) - { - SiebAktivieren(x, y, 1); - sieb = TRUE; - } - else if (element == EL_BD_MAGIC_WALL_FULL || - element == EL_BD_MAGIC_WALL_ACTIVE || - element == EL_BD_MAGIC_WALL_EMPTYING) - { - SiebAktivieren(x, y, 2); - sieb = TRUE; - } - /* play the element sound at the position nearest to the player */ - if (sieb && ABS(x-jx)+ABS(y-jy) < ABS(sieb_x-jx)+ABS(sieb_y-jy)) + if ((element == EL_MAGIC_WALL_FULL || + element == EL_MAGIC_WALL_ACTIVE || + element == EL_MAGIC_WALL_EMPTYING || + element == EL_BD_MAGIC_WALL_FULL || + element == EL_BD_MAGIC_WALL_ACTIVE || + element == EL_BD_MAGIC_WALL_EMPTYING) && + ABS(x-jx) + ABS(y-jy) < ABS(magic_wall_x-jx) + ABS(magic_wall_y-jy)) { - sieb_x = x; - sieb_y = y; + magic_wall_x = x; + magic_wall_y = y; } } } @@ -5460,14 +4784,14 @@ void GameActions() { if (!(game.magic_wall_time_left % 4)) { - int element = Feld[sieb_x][sieb_y]; + int element = Feld[magic_wall_x][magic_wall_y]; if (element == EL_BD_MAGIC_WALL_FULL || element == EL_BD_MAGIC_WALL_ACTIVE || element == EL_BD_MAGIC_WALL_EMPTYING) - PlaySoundLevel(sieb_x, sieb_y, SND_BD_MAGIC_WALL_ACTIVE); + PlaySoundLevel(magic_wall_x, magic_wall_y, SND_BD_MAGIC_WALL_ACTIVE); else - PlaySoundLevel(sieb_x, sieb_y, SND_MAGIC_WALL_ACTIVE); + PlaySoundLevel(magic_wall_x, magic_wall_y, SND_MAGIC_WALL_ACTIVE); } if (game.magic_wall_time_left > 0) @@ -5553,16 +4877,16 @@ void GameActions() TimeLeft--; if (TimeLeft <= 10 && setup.time_limit) - PlaySoundStereo(SND_GAME_RUNNING_OUT_OF_TIME, SOUND_MAX_RIGHT); + PlaySoundStereo(SND_GAME_RUNNING_OUT_OF_TIME, SOUND_MIDDLE); - DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); + DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FONT_TEXT_2); if (!TimeLeft && setup.time_limit) for (i=0; iprogrammed_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) { @@ -5716,8 +5074,8 @@ boolean MoveFigureOneStep(struct PlayerInfo *player, { if (element == EL_ACID && dx == 0 && dy == 1) { - Blurb(jx, jy); - Feld[jx][jy] = EL_PLAYER1; + SplashAcid(jx, jy); + Feld[jx][jy] = EL_PLAYER_1; InitMovingField(jx, jy, MV_DOWN); Store[jx][jy] = EL_ACID; ContinueMoving(jx, jy); @@ -5880,15 +5238,17 @@ 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; +#if 1 + InitPlayerGfxAnimation(player, ACTION_DEFAULT); #else - player->Frame += 1 * 0; + if (!(moved & MF_MOVING) && !player->Pushing) + player->Frame = 0; +#endif #endif + player->StepFrame = 0; + if (moved & MF_MOVING) { if (old_jx != jx && old_jy == jy) @@ -5896,7 +5256,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; @@ -5932,8 +5292,6 @@ 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; @@ -5946,7 +5304,6 @@ 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; @@ -5959,7 +5316,7 @@ void ScrollFigure(struct PlayerInfo *player, int mode) if (player->MovPos == 0) { - if (IS_QUICK_GATE(Feld[last_jx][last_jy])) + if (IS_WALKABLE_THROUGH(Feld[last_jx][last_jy])) { /* continue with normal speed after quickly moving through gate */ HALVE_PLAYER_SPEED(player); @@ -6227,8 +5584,8 @@ void TestIfBadThingTouchesOtherBadThing(int bad_x, int bad_y) continue; element = Feld[x][y]; - if (IS_AMOEBOID(element) || element == EL_GAMEOFLIFE || - element == EL_AMOEBA_CREATING || element == EL_AMOEBA_DROP) + if (IS_AMOEBOID(element) || element == EL_GAME_OF_LIFE || + element == EL_AMOEBA_GROWING || element == EL_AMOEBA_DROP) { kill_x = x; kill_y = y; @@ -6271,7 +5628,7 @@ void BuryHero(struct PlayerInfo *player) if (!player->active) return; - PlaySoundLevel(jx, jy, SND_PLAYER_DYING); + PlaySoundLevel(jx, jy, SND_CLASS_PLAYER_DYING); PlaySoundLevel(jx, jy, SND_GAME_LOSING); player->GameOver = TRUE; @@ -6300,6 +5657,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) { @@ -6311,6 +5687,12 @@ int DigField(struct PlayerInfo *player, dy == +1 ? MV_DOWN : MV_NO_MOVING); int element; + if (player->MovPos == 0) + { + player->is_digging = FALSE; + player->is_collecting = FALSE; + } + if (player->MovPos == 0) player->Pushing = FALSE; @@ -6324,12 +5706,12 @@ int DigField(struct PlayerInfo *player, if (IS_MOVING(x, y) || IS_PLAYER(x, y)) return MF_NO_ACTION; - if (IS_TUBE(Feld[jx][jy])) + if (IS_WALKABLE_UNDER(Feld[jx][jy])) { int i = 0; int tube_leave_directions[][2] = { - { EL_TUBE_ALL, MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN }, + { EL_TUBE_ANY, MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN }, { EL_TUBE_VERTICAL, MV_UP | MV_DOWN }, { EL_TUBE_HORIZONTAL, MV_LEFT | MV_RIGHT }, { EL_TUBE_VERTICAL_LEFT, MV_LEFT | MV_UP | MV_DOWN }, @@ -6367,7 +5749,14 @@ int DigField(struct PlayerInfo *player, case EL_SP_BUGGY_BASE: case EL_SP_BUGGY_BASE_ACTIVATING: RemoveField(x, y); - PlaySoundLevelElementAction(x, y, element, SND_ACTION_DIGGING); +#if 1 + if (mode != DF_SNAP && element != EL_EMPTY) + { + GfxElement[x][y] = (CAN_BE_CRUMBLED(element) ? EL_SAND : element); + player->is_digging = TRUE; + } +#endif + PlaySoundLevelElementAction(x, y, element, ACTION_DIGGING); break; case EL_EMERALD: @@ -6380,6 +5769,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); @@ -6387,9 +5783,8 @@ int DigField(struct PlayerInfo *player, local_player->gems_still_needed = 0; RaiseScoreElement(element); DrawText(DX_EMERALDS, DY_EMERALDS, - int2str(local_player->gems_still_needed, 3), - FS_SMALL, FC_YELLOW); - PlaySoundLevelElementAction(x, y, element, SND_ACTION_COLLECTING); + int2str(local_player->gems_still_needed, 3), FONT_TEXT_2); + PlaySoundLevelElementAction(x, y, element, ACTION_COLLECTING); break; case EL_SPEED_PILL: @@ -6408,9 +5803,9 @@ int DigField(struct PlayerInfo *player, if (level.time > 0) { TimeLeft += 10; - DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); + DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FONT_TEXT_2); } - PlaySoundStereo(SND_EXTRA_TIME_COLLECTING, SOUND_MAX_RIGHT); + PlaySoundStereo(SND_EXTRA_TIME_COLLECTING, SOUND_MIDDLE); break; case EL_SHIELD_NORMAL: @@ -6430,68 +5825,70 @@ int DigField(struct PlayerInfo *player, case EL_SP_DISK_RED: RemoveField(x, y); player->dynamite++; + player->use_disk_red_graphic = (element == EL_SP_DISK_RED); RaiseScoreElement(EL_DYNAMITE); - DrawText(DX_DYNAMITE, DY_DYNAMITE, - int2str(local_player->dynamite, 3), - FS_SMALL, FC_YELLOW); - PlaySoundLevelElementAction(x, y, element, SND_ACTION_COLLECTING); + DrawText(DX_DYNAMITE, DY_DYNAMITE, int2str(local_player->dynamite, 3), + FONT_TEXT_2); + PlaySoundLevelElementAction(x, y, element, ACTION_COLLECTING); break; - case EL_DYNABOMB_NR: + case EL_DYNABOMB_INCREASE_NUMBER: RemoveField(x, y); player->dynabomb_count++; player->dynabombs_left++; RaiseScoreElement(EL_DYNAMITE); - PlaySoundLevel(x, y, SND_DYNABOMB_NR_COLLECTING); + PlaySoundLevel(x, y, SND_DYNABOMB_INCREASE_NUMBER_COLLECTING); break; - case EL_DYNABOMB_SZ: + case EL_DYNABOMB_INCREASE_SIZE: RemoveField(x, y); player->dynabomb_size++; RaiseScoreElement(EL_DYNAMITE); - PlaySoundLevel(x, y, SND_DYNABOMB_SZ_COLLECTING); + PlaySoundLevel(x, y, SND_DYNABOMB_INCREASE_SIZE_COLLECTING); break; - case EL_DYNABOMB_XL: + case EL_DYNABOMB_INCREASE_POWER: RemoveField(x, y); player->dynabomb_xl = TRUE; RaiseScoreElement(EL_DYNAMITE); - PlaySoundLevel(x, y, SND_DYNABOMB_XL_COLLECTING); + PlaySoundLevel(x, y, SND_DYNABOMB_INCREASE_POWER_COLLECTING); break; - case EL_KEY1: - case EL_KEY2: - case EL_KEY3: - case EL_KEY4: + case EL_KEY_1: + case EL_KEY_2: + case EL_KEY_3: + case EL_KEY_4: { - int key_nr = element - EL_KEY1; + int key_nr = element - EL_KEY_1; + int graphic = el2edimg(element); RemoveField(x, y); player->key[key_nr] = TRUE; RaiseScoreElement(element); DrawMiniGraphicExt(drawto, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS, - IMG_KEY1 + key_nr); + graphic); DrawMiniGraphicExt(window, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS, - IMG_KEY1 + key_nr); - PlaySoundLevel(x, y, SND_KEY_COLLECTING); + graphic); + PlaySoundLevel(x, y, SND_CLASS_KEY_COLLECTING); break; } - case EL_EM_KEY1: - case EL_EM_KEY2: - case EL_EM_KEY3: - case EL_EM_KEY4: + 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_KEY1; + int key_nr = element - EL_EM_KEY_1; + int graphic = el2edimg(EL_KEY_1 + key_nr); RemoveField(x, y); player->key[key_nr] = TRUE; RaiseScoreElement(element); DrawMiniGraphicExt(drawto, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS, - IMG_KEY1 + key_nr); + graphic); DrawMiniGraphicExt(window, DX_KEYS + key_nr * MINI_TILEX, DY_KEYS, - IMG_KEY1 + key_nr); - PlaySoundLevel(x, y, SND_KEY_COLLECTING); + graphic); + PlaySoundLevel(x, y, SND_CLASS_KEY_COLLECTING); break; } @@ -6525,23 +5922,23 @@ int DigField(struct PlayerInfo *player, } break; - case EL_CONVEYOR_BELT1_SWITCH_LEFT: - case EL_CONVEYOR_BELT1_SWITCH_MIDDLE: - case EL_CONVEYOR_BELT1_SWITCH_RIGHT: - case EL_CONVEYOR_BELT2_SWITCH_LEFT: - case EL_CONVEYOR_BELT2_SWITCH_MIDDLE: - case EL_CONVEYOR_BELT2_SWITCH_RIGHT: - case EL_CONVEYOR_BELT3_SWITCH_LEFT: - case EL_CONVEYOR_BELT3_SWITCH_MIDDLE: - case EL_CONVEYOR_BELT3_SWITCH_RIGHT: - case EL_CONVEYOR_BELT4_SWITCH_LEFT: - case EL_CONVEYOR_BELT4_SWITCH_MIDDLE: - case EL_CONVEYOR_BELT4_SWITCH_RIGHT: + case EL_CONVEYOR_BELT_1_SWITCH_LEFT: + case EL_CONVEYOR_BELT_1_SWITCH_MIDDLE: + case EL_CONVEYOR_BELT_1_SWITCH_RIGHT: + case EL_CONVEYOR_BELT_2_SWITCH_LEFT: + case EL_CONVEYOR_BELT_2_SWITCH_MIDDLE: + case EL_CONVEYOR_BELT_2_SWITCH_RIGHT: + case EL_CONVEYOR_BELT_3_SWITCH_LEFT: + case EL_CONVEYOR_BELT_3_SWITCH_MIDDLE: + case EL_CONVEYOR_BELT_3_SWITCH_RIGHT: + case EL_CONVEYOR_BELT_4_SWITCH_LEFT: + case EL_CONVEYOR_BELT_4_SWITCH_MIDDLE: + case EL_CONVEYOR_BELT_4_SWITCH_RIGHT: if (!player->Switching) { player->Switching = TRUE; ToggleBeltSwitch(x, y); - PlaySoundLevel(x, y, SND_CONVEYOR_BELT_SWITCH_ACTIVATING); + PlaySoundLevel(x, y, SND_CLASS_CONVEYOR_BELT_SWITCH_ACTIVATING); } return MF_ACTION; break; @@ -6552,7 +5949,7 @@ int DigField(struct PlayerInfo *player, { player->Switching = TRUE; ToggleSwitchgateSwitch(x, y); - PlaySoundLevel(x, y, SND_SWITCHGATE_SWITCH_ACTIVATING); + PlaySoundLevel(x, y, SND_CLASS_SWITCHGATE_SWITCH_ACTIVATING); } return MF_ACTION; break; @@ -6577,20 +5974,20 @@ int DigField(struct PlayerInfo *player, return MF_ACTION; break; - case EL_BALLOON_SEND_LEFT: - case EL_BALLOON_SEND_RIGHT: - case EL_BALLOON_SEND_UP: - case EL_BALLOON_SEND_DOWN: - case EL_BALLOON_SEND_ANY_DIRECTION: - if (element == EL_BALLOON_SEND_ANY_DIRECTION) + case EL_BALLOON_SWITCH_LEFT: + case EL_BALLOON_SWITCH_RIGHT: + case EL_BALLOON_SWITCH_UP: + case EL_BALLOON_SWITCH_DOWN: + case EL_BALLOON_SWITCH_ANY: + if (element == EL_BALLOON_SWITCH_ANY) game.balloon_dir = move_direction; else - game.balloon_dir = (element == EL_BALLOON_SEND_LEFT ? MV_LEFT : - element == EL_BALLOON_SEND_RIGHT ? MV_RIGHT : - element == EL_BALLOON_SEND_UP ? MV_UP : - element == EL_BALLOON_SEND_DOWN ? MV_DOWN : + game.balloon_dir = (element == EL_BALLOON_SWITCH_LEFT ? MV_LEFT : + element == EL_BALLOON_SWITCH_RIGHT ? MV_RIGHT : + element == EL_BALLOON_SWITCH_UP ? MV_UP : + element == EL_BALLOON_SWITCH_DOWN ? MV_DOWN : MV_NO_MOVING); - PlaySoundLevel(x, y, SND_BALLOON_SWITCH_ACTIVATING); + PlaySoundLevel(x, y, SND_CLASS_BALLOON_SWITCH_ACTIVATING); return MF_ACTION; break; @@ -6606,7 +6003,9 @@ int DigField(struct PlayerInfo *player, case EL_SPRING: if (mode == DF_SNAP) return MF_NO_ACTION; + /* no "break" -- fall through to next case */ + /* the following elements can be pushed by "snapping" */ case EL_BD_ROCK: if (dy) @@ -6627,7 +6026,8 @@ int DigField(struct PlayerInfo *player, player->push_delay = FrameCounter; #if 0 if (!FrameReached(&player->push_delay, player->push_delay_value) && - !tape.playing && element != EL_SPRING) + !tape.playing && + element != EL_SPRING) return MF_NO_ACTION; #else if (!FrameReached(&player->push_delay, player->push_delay_value) && @@ -6656,30 +6056,30 @@ int DigField(struct PlayerInfo *player, player->push_delay_value = (element == EL_SPRING ? 0 : 2 + RND(8)); DrawLevelField(x + dx, y + dy); - PlaySoundLevelElementAction(x, y, element, SND_ACTION_PUSHING); + PlaySoundLevelElementAction(x, y, element, ACTION_PUSHING); break; - case EL_GATE1: - case EL_GATE2: - case EL_GATE3: - case EL_GATE4: - if (!player->key[element - EL_GATE1]) + case EL_GATE_1: + case EL_GATE_2: + case EL_GATE_3: + case EL_GATE_4: + if (!player->key[element - EL_GATE_1]) return MF_NO_ACTION; break; - case EL_GATE1_GRAY: - case EL_GATE2_GRAY: - case EL_GATE3_GRAY: - case EL_GATE4_GRAY: - if (!player->key[element - EL_GATE1_GRAY]) + case EL_GATE_1_GRAY: + case EL_GATE_2_GRAY: + case EL_GATE_3_GRAY: + case EL_GATE_4_GRAY: + if (!player->key[element - EL_GATE_1_GRAY]) return MF_NO_ACTION; break; - case EL_EM_GATE1: - case EL_EM_GATE2: - case EL_EM_GATE3: - case EL_EM_GATE4: - if (!player->key[element - EL_EM_GATE1]) + 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; @@ -6688,14 +6088,14 @@ int DigField(struct PlayerInfo *player, player->programmed_action = move_direction; DOUBLE_PLAYER_SPEED(player); - PlaySoundLevel(x, y, SND_GATE_PASSING); + PlaySoundLevel(x, y, SND_CLASS_GATE_PASSING); break; - case EL_EM_GATE1_GRAY: - case EL_EM_GATE2_GRAY: - case EL_EM_GATE3_GRAY: - case EL_EM_GATE4_GRAY: - if (!player->key[element - EL_EM_GATE1_GRAY]) + case EL_EM_GATE_1_GRAY: + case EL_EM_GATE_2_GRAY: + case EL_EM_GATE_3_GRAY: + case EL_EM_GATE_4_GRAY: + if (!player->key[element - EL_EM_GATE_1_GRAY]) return MF_NO_ACTION; if (!IN_LEV_FIELD(x + dx, y + dy) || !IS_FREE(x + dx, y + dy)) return MF_NO_ACTION; @@ -6704,7 +6104,11 @@ 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_GATE_PASSING); +#endif break; case EL_SWITCHGATE_OPEN: @@ -6716,40 +6120,40 @@ int DigField(struct PlayerInfo *player, player->programmed_action = move_direction; DOUBLE_PLAYER_SPEED(player); - PlaySoundLevelElementAction(x, y, element, SND_ACTION_PASSING); + PlaySoundLevelElementAction(x, y, element, ACTION_PASSING); break; - case EL_SP_PORT1_LEFT: - case EL_SP_PORT2_LEFT: - case EL_SP_PORT1_RIGHT: - case EL_SP_PORT2_RIGHT: - case EL_SP_PORT1_UP: - case EL_SP_PORT2_UP: - case EL_SP_PORT1_DOWN: - case EL_SP_PORT2_DOWN: - case EL_SP_PORT_X: - case EL_SP_PORT_Y: - case EL_SP_PORT_XY: + case EL_SP_PORT_LEFT: + case EL_SP_PORT_RIGHT: + case EL_SP_PORT_UP: + case EL_SP_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_PORT1_LEFT && - element != EL_SP_PORT2_LEFT && - element != EL_SP_PORT_X && - element != EL_SP_PORT_XY) || + element != EL_SP_PORT_LEFT && + element != EL_SP_GRAVITY_PORT_LEFT && + element != EL_SP_PORT_HORIZONTAL && + element != EL_SP_PORT_ANY) || (dx == +1 && - element != EL_SP_PORT1_RIGHT && - element != EL_SP_PORT2_RIGHT && - element != EL_SP_PORT_X && - element != EL_SP_PORT_XY) || + element != EL_SP_PORT_RIGHT && + element != EL_SP_GRAVITY_PORT_RIGHT && + element != EL_SP_PORT_HORIZONTAL && + element != EL_SP_PORT_ANY) || (dy == -1 && - element != EL_SP_PORT1_UP && - element != EL_SP_PORT2_UP && - element != EL_SP_PORT_Y && - element != EL_SP_PORT_XY) || + element != EL_SP_PORT_UP && + element != EL_SP_GRAVITY_PORT_UP && + element != EL_SP_PORT_VERTICAL && + element != EL_SP_PORT_ANY) || (dy == +1 && - element != EL_SP_PORT1_DOWN && - element != EL_SP_PORT2_DOWN && - element != EL_SP_PORT_Y && - element != EL_SP_PORT_XY) || + element != EL_SP_PORT_DOWN && + element != EL_SP_GRAVITY_PORT_DOWN && + element != EL_SP_PORT_VERTICAL && + element != EL_SP_PORT_ANY) || !IN_LEV_FIELD(x + dx, y + dy) || !IS_FREE(x + dx, y + dy)) return MF_NO_ACTION; @@ -6758,10 +6162,10 @@ int DigField(struct PlayerInfo *player, player->programmed_action = move_direction; DOUBLE_PLAYER_SPEED(player); - PlaySoundLevel(x, y, SND_SP_PORT_PASSING); + PlaySoundLevel(x, y, SND_CLASS_SP_PORT_PASSING); break; - case EL_TUBE_ALL: + case EL_TUBE_ANY: case EL_TUBE_VERTICAL: case EL_TUBE_HORIZONTAL: case EL_TUBE_VERTICAL_LEFT: @@ -6776,7 +6180,7 @@ int DigField(struct PlayerInfo *player, int i = 0; int tube_enter_directions[][2] = { - { EL_TUBE_ALL, MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN }, + { EL_TUBE_ANY, MV_LEFT | MV_RIGHT | MV_UP | MV_DOWN }, { EL_TUBE_VERTICAL, MV_UP | MV_DOWN }, { EL_TUBE_HORIZONTAL, MV_LEFT | MV_RIGHT }, { EL_TUBE_VERTICAL_LEFT, MV_RIGHT | MV_UP | MV_DOWN }, @@ -6800,7 +6204,7 @@ int DigField(struct PlayerInfo *player, if (!(tube_enter_directions[i][1] & move_direction)) return MF_NO_ACTION; /* tube has no opening in this direction */ - PlaySoundLevel(x, y, SND_TUBE_PASSING); + PlaySoundLevel(x, y, SND_CLASS_TUBE_PASSING); } break; @@ -6816,9 +6220,9 @@ int DigField(struct PlayerInfo *player, return MF_NO_ACTION; if (element == EL_EXIT_OPEN) - PlaySoundLevel(x, y, SND_EXIT_PASSING); + PlaySoundLevel(x, y, SND_CLASS_EXIT_PASSING); else - PlaySoundLevel(x, y, SND_SP_EXIT_PASSING); + PlaySoundLevel(x, y, SND_CLASS_SP_EXIT_PASSING); break; @@ -6833,9 +6237,9 @@ int DigField(struct PlayerInfo *player, case EL_TIME_ORB_FULL: Feld[x][y] = EL_TIME_ORB_EMPTY; TimeLeft += 10; - DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); + DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FONT_TEXT_2); DrawLevelField(x, y); - PlaySoundStereo(SND_TIME_ORB_FULL_COLLECTING, SOUND_MAX_RIGHT); + PlaySoundStereo(SND_TIME_ORB_FULL_COLLECTING, SOUND_MIDDLE); return MF_ACTION; break; @@ -6897,24 +6301,40 @@ int DigField(struct PlayerInfo *player, Feld[x+dx][y+dy] = EL_SOKOBAN_FIELD_FULL; local_player->sokobanfields_still_needed--; if (element == EL_SOKOBAN_OBJECT) - PlaySoundLevel(x, y, SND_SOKOBAN_FIELD_FILLING); +#if 1 + PlaySoundLevelAction(x+dx, y+dy, ACTION_FILLING); +#else + PlaySoundLevel(x, y, SND_CLASS_SOKOBAN_FIELD_FILLING); +#endif else +#if 1 + PlaySoundLevelAction(x+dx, y+dy, ACTION_PUSHING); +#else PlaySoundLevel(x, y, SND_SOKOBAN_OBJECT_PUSHING); +#endif } else { Feld[x+dx][y+dy] = EL_SOKOBAN_OBJECT; if (element == EL_SOKOBAN_FIELD_FULL) +#if 1 + PlaySoundLevelAction(x+dx, y+dy, ACTION_EMPTYING); +#else PlaySoundLevel(x, y, SND_SOKOBAN_FIELD_EMPTYING); +#endif else +#if 1 + PlaySoundLevelAction(x+dx, y+dy, ACTION_PUSHING); +#else PlaySoundLevel(x, y, SND_SOKOBAN_OBJECT_PUSHING); +#endif } } else { RemoveField(x, y); Feld[x+dx][y+dy] = element; - PlaySoundLevelElementAction(x, y, element, SND_ACTION_PUSHING); + PlaySoundLevelElementAction(x, y, element, ACTION_PUSHING); } player->push_delay_value = (element == EL_BALLOON ? 0 : 2); @@ -6927,7 +6347,7 @@ int DigField(struct PlayerInfo *player, game.emulation == EMU_SOKOBAN) { player->LevelSolved = player->GameOver = TRUE; - PlaySoundLevel(x, y, SND_SOKOBAN_GAME_SOLVING); + PlaySoundLevel(x, y, SND_GAME_SOKOBAN_SOLVING); } break; @@ -6938,11 +6358,56 @@ int DigField(struct PlayerInfo *player, break; default: + if (IS_PUSHABLE(element)) + { + if (mode == DF_SNAP) + return MF_NO_ACTION; + + if (CAN_FALL(element) && dy) + return MF_NO_ACTION; + + player->Pushing = TRUE; + + if (!IN_LEV_FIELD(x+dx, y+dy) || !IS_FREE(x+dx, y+dy)) + return MF_NO_ACTION; + + if (dx && real_dy) + { + if (IN_LEV_FIELD(jx, jy+real_dy) && !IS_SOLID(Feld[jx][jy+real_dy])) + return MF_NO_ACTION; + } + else if (dy && real_dx) + { + if (IN_LEV_FIELD(jx+real_dx, jy) && !IS_SOLID(Feld[jx+real_dx][jy])) + return MF_NO_ACTION; + } + + if (player->push_delay == 0) + player->push_delay = FrameCounter; + + if (!FrameReached(&player->push_delay, player->push_delay_value) && + !(tape.playing && tape.file_version < FILE_VERSION_2_0)) + return MF_NO_ACTION; + + RemoveField(x, y); + Feld[x + dx][y + dy] = element; + + player->push_delay_value = 2 + RND(8); + + DrawLevelField(x + dx, y + dy); + PlaySoundLevelElementAction(x, y, element, ACTION_PUSHING); + + break; + } + return MF_NO_ACTION; } player->push_delay = 0; + if (Feld[x][y] != element) /* really digged/collected something */ + player->is_collecting = !player->is_digging; + return MF_MOVING; } @@ -6963,6 +6428,13 @@ boolean SnapField(struct PlayerInfo *player, int dx, int dy) player->Pushing = FALSE; player->snapped = FALSE; + + if (player->MovPos == 0) + { + player->is_digging = FALSE; + player->is_collecting = FALSE; + } + return FALSE; } @@ -6978,6 +6450,9 @@ boolean SnapField(struct PlayerInfo *player, int dx, int dy) return FALSE; player->snapped = TRUE; + player->is_digging = FALSE; + player->is_collecting = FALSE; + DrawLevelField(x, y); BackToFront(); @@ -7002,44 +6477,70 @@ boolean PlaceBomb(struct PlayerInfo *player) Store[jx][jy] = element; MovDelay[jx][jy] = 96; - GfxFrame[jx][jy] = 0; + + ResetGfxAnimation(jx, jy); + ResetRandomAnimationValue(jx, jy); if (player->dynamite) { - Feld[jx][jy] = EL_DYNAMITE_ACTIVE; + Feld[jx][jy] = (player->use_disk_red_graphic ? EL_SP_DISK_RED_ACTIVE : + EL_DYNAMITE_ACTIVE); player->dynamite--; DrawText(DX_DYNAMITE, DY_DYNAMITE, int2str(local_player->dynamite, 3), - FS_SMALL, FC_YELLOW); + FONT_TEXT_2); if (IN_SCR_FIELD(SCREENX(jx), SCREENY(jy))) { +#if 1 + DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), el2img(Feld[jx][jy]), 0); +#else if (game.emulation == EMU_SUPAPLEX) DrawGraphic(SCREENX(jx), SCREENY(jy), IMG_SP_DISK_RED, 0); else DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), IMG_DYNAMITE_ACTIVE, 0); +#endif } - PlaySoundLevel(jx, jy, SND_DYNAMITE_DROPPING); + PlaySoundLevelAction(jx, jy, ACTION_DROPPING); } else { Feld[jx][jy] = - EL_DYNABOMB_PLAYER1_ACTIVE + (player->element_nr - EL_PLAYER1); + EL_DYNABOMB_PLAYER_1_ACTIVE + (player->element_nr - EL_PLAYER_1); player->dynabombs_left--; if (IN_SCR_FIELD(SCREENX(jx), SCREENY(jy))) DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), el2img(Feld[jx][jy]), 0); - PlaySoundLevel(jx, jy, SND_DYNABOMB_DROPPING); + PlaySoundLevelAction(jx, jy, ACTION_DROPPING); } return TRUE; } +/* ------------------------------------------------------------------------- */ +/* game sound playing functions */ +/* ------------------------------------------------------------------------- */ + +static int *loop_sound_frame = NULL; +static int *loop_sound_volume = NULL; + +void InitPlaySoundLevel() +{ + int num_sounds = getSoundListSize(); + + if (loop_sound_frame != NULL) + free(loop_sound_frame); + + if (loop_sound_volume != NULL) + free(loop_sound_volume); + + loop_sound_frame = checked_calloc(num_sounds * sizeof(int)); + loop_sound_volume = checked_calloc(num_sounds * sizeof(int)); +} + static void PlaySoundLevel(int x, int y, int nr) { - static int loop_sound_frame[NUM_SOUND_FILES]; - static int loop_sound_volume[NUM_SOUND_FILES]; int sx = SCREENX(x), sy = SCREENY(y); int volume, stereo_position; int max_distance = 8; @@ -7092,25 +6593,39 @@ static void PlaySoundLevelNearest(int x, int y, int sound_action) sound_action); } -static void PlaySoundLevelAction(int x, int y, int sound_action) +static void PlaySoundLevelAction(int x, int y, int action) +{ + PlaySoundLevelElementAction(x, y, Feld[x][y], action); +} + +static void PlaySoundLevelElementAction(int x, int y, int element, int action) { - PlaySoundLevelElementAction(x, y, Feld[x][y], sound_action); + int sound_effect = element_info[element].sound[action]; + + if (sound_effect != SND_UNDEFINED) + PlaySoundLevel(x, y, sound_effect); } -static void PlaySoundLevelElementAction(int x, int y, int element, - int sound_action) +static void PlaySoundLevelActionIfLoop(int x, int y, int action) { - int sound_effect = element_action_sound[element][sound_action]; + int sound_effect = element_info[Feld[x][y]].sound[action]; - if (sound_effect != -1) + if (sound_effect != SND_UNDEFINED && IS_LOOP_SOUND(sound_effect)) PlaySoundLevel(x, y, sound_effect); } +static void StopSoundLevelActionIfLoop(int x, int y, int action) +{ + int sound_effect = element_info[Feld[x][y]].sound[action]; + + if (sound_effect != SND_UNDEFINED && IS_LOOP_SOUND(sound_effect)) + StopSoundExt(sound_effect, SND_CTRL_STOP_SOUND); +} + void RaiseScore(int value) { local_player->score += value; - DrawText(DX_SCORE, DY_SCORE, int2str(local_player->score, 5), - FS_SMALL, FC_YELLOW); + DrawText(DX_SCORE, DY_SCORE, int2str(local_player->score, 5), FONT_TEXT_2); } void RaiseScoreElement(int element) @@ -7122,22 +6637,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]); @@ -7146,16 +6661,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_KEY1: - case EL_KEY2: - case EL_KEY3: - case EL_KEY4: - RaiseScore(level.score[SC_SCHLUESSEL]); + case EL_KEY_1: + case EL_KEY_2: + case EL_KEY_3: + case EL_KEY_4: + RaiseScore(level.score[SC_KEY]); break; default: break; @@ -7249,7 +6764,7 @@ void CreateGameButtons() for (i=0; i