X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=9dca25854cf41ca1b13b79267f3d8323b54acaf4;hb=0d0e1a63d6b14109b64805bcb1a45ddf469ba35d;hp=ea346bfd599ddbd287013bf79259c1aa7517bfcd;hpb=4be46f1030df4cb7db0ce7c46d2518334861731a;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index ea346bfd..9dca2585 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,15 +101,20 @@ #define NUM_GAME_BUTTONS 6 + /* forward declaration for internal use */ + static void InitBeltMovement(void); static void CloseAllOpenTimegates(void); static void CheckGravityMovement(struct PlayerInfo *); static void KillHeroUnlessProtected(int, int); -void PlaySoundLevel(int, int, int); -void PlaySoundLevelAction(int, int, int); -void PlaySoundLevelElementAction(int, int, int, int); +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 *); @@ -116,56 +123,24 @@ static struct GadgetInfo *game_gadget[NUM_GAME_BUTTONS]; /* ------------------------------------------------------------------------- */ -/* 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]; +/* forward declaration for changer functions */ +static void InitBuggyBase(int x, int y); +static void WarnBuggyBase(int x, int y); -#define IS_LOOP_SOUND(x) (is_loop_sound[x]) +static void InitTrap(int x, int y); +static void ActivateTrap(int x, int y); +static void ChangeActiveTrap(int x, int y); +static void InitRobotWheel(int x, int y); +static void RunRobotWheel(int x, int y); +static void StopRobotWheel(int x, int y); -/* ------------------------------------------------------------------------- - definition of elements that automatically change to other elements after - a specified time, eventually calling a function when changing - ------------------------------------------------------------------------- */ +static void InitTimegateWheel(int x, int y); +static void RunTimegateWheel(int x, int y); struct ChangingElementInfo { @@ -179,74 +154,43 @@ 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 }, + { EL_SWITCHGATE_OPENING, EL_SWITCHGATE_OPEN, 29, NULL, NULL, NULL }, { EL_SWITCHGATE_CLOSING, EL_SWITCHGATE_CLOSED, 29, NULL, NULL, NULL }, + { EL_TIMEGATE_OPENING, EL_TIMEGATE_OPEN, 29, NULL, NULL, NULL }, { EL_TIMEGATE_CLOSING, EL_TIMEGATE_CLOSED, 29, NULL, NULL, NULL }, - { EL_UNDEFINED, EL_UNDEFINED, -1, NULL } -}; - -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; + { EL_ACID_SPLASH_LEFT, EL_EMPTY, 8, NULL, NULL, NULL }, + { EL_ACID_SPLASH_RIGHT, EL_EMPTY, 8, NULL, NULL, NULL }, - for (y=0; yjx, jy = player->jy; player->present = TRUE; @@ -374,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: @@ -431,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; @@ -461,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]); @@ -527,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; + Properties2[EL_EXPANDABLE_WALL_GROWING] |= EP_BIT_EM_SLIPPERY_WALL; else - Properties2[EL_WALL_GROWING_ACTIVE] &=~EP_BIT_EM_SLIPPERY_WALL; + Properties2[EL_EXPANDABLE_WALL_GROWING] &=~EP_BIT_EM_SLIPPERY_WALL; } /* initialize changing elements information */ @@ -757,7 +614,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; @@ -786,15 +643,22 @@ 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->move_delay = game.initial_move_delay; player->move_delay_value = game.initial_move_delay_value; @@ -871,7 +735,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; } } @@ -1043,19 +909,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, FONT_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); } @@ -1249,7 +1115,7 @@ void GameWon() 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) @@ -1275,7 +1141,7 @@ void GameWon() 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) @@ -1286,10 +1152,6 @@ void GameWon() StopSound(SND_GAME_LEVELTIME_BONUS); } -#if 0 - FadeSounds(); -#endif - /* Hero disappears */ DrawLevelField(ExitX, ExitY); BackToFront(); @@ -1400,6 +1262,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]; @@ -1407,18 +1296,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) @@ -1519,7 +1411,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; @@ -1529,7 +1421,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); @@ -1547,46 +1439,47 @@ void DrawDynamite(int x, int y) if (Store[x][y]) DrawGraphic(sx, sy, el2img(Store[x][y]), 0); - frame = getGraphicAnimationFrame(graphic, 96 - MovDelay[x][y]); - - /* - printf("-> %d: %d [%d]\n", graphic, frame, MovDelay[x][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, 0); + 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) { - if (MovDelay[x][y]) /* dynamite is still waiting to explode */ + if (MovDelay[x][y] != 0) /* dynamite is still waiting to explode */ { MovDelay[x][y]--; - if (MovDelay[x][y]) - { - if (!(MovDelay[x][y] % 6)) - PlaySoundLevelAction(x, y, SND_ACTION_ACTIVE); - - if (IS_ACTIVE_BOMB(Feld[x][y])) - { - int delay = (Feld[x][y] == EL_DYNAMITE_ACTIVE ? 12 : 6); - if (!(MovDelay[x][y] % delay)) - DrawDynamite(x, y); - } + if (MovDelay[x][y] != 0) + { + 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); } @@ -1635,7 +1528,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))) @@ -1657,16 +1550,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; @@ -1715,7 +1608,7 @@ 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]]--; @@ -1821,7 +1714,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++; @@ -1837,7 +1730,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]; @@ -1885,13 +1778,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: @@ -1908,52 +1801,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); - } - } } } @@ -1961,17 +1826,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; @@ -1987,9 +1852,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; } } @@ -2022,24 +1887,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] = { @@ -2071,9 +1936,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=0 && ZY>=0) + if (element == EL_ROBOT && ZX >= 0 && ZY >= 0) { attr_x = ZX; attr_y = ZY; @@ -2886,7 +2774,7 @@ void StartMoving(int x, int y) if (Stop[x][y]) return; - GfxAction[x][y] = GFX_ACTION_DEFAULT; + GfxAction[x][y] = ACTION_DEFAULT; if (CAN_FALL(element) && y < lev_fieldy - 1) { @@ -2903,7 +2791,11 @@ void StartMoving(int x, int y) Feld[x][y] = EL_QUICKSAND_EMPTYING; Store[x][y] = EL_ROCK; +#if 1 + PlaySoundLevelAction(x, y, ACTION_EMPTYING); +#else PlaySoundLevel(x, y, SND_QUICKSAND_EMPTYING); +#endif } else if (Feld[x][y+1] == EL_QUICKSAND_EMPTY) { @@ -2921,7 +2813,11 @@ void StartMoving(int x, int y) Feld[x][y+1] = EL_QUICKSAND_FULL; Store[x][y+1] = Store[x][y]; Store[x][y] = 0; - PlaySoundLevel(x, y, SND_QUICKSAND_SLIPPING); +#if 1 + PlaySoundLevelAction(x, y, ACTION_FILLING); +#else + PlaySoundLevel(x, y, SND_QUICKSAND_FILLING); +#endif } } else if ((element == EL_ROCK || element == EL_BD_ROCK) && @@ -2932,7 +2828,11 @@ void StartMoving(int x, int y) Feld[x][y] = EL_QUICKSAND_FILLING; Store[x][y] = element; +#if 1 + PlaySoundLevelAction(x, y, ACTION_FILLING); +#else PlaySoundLevel(x, y, SND_QUICKSAND_FILLING); +#endif } else if (element == EL_MAGIC_WALL_FULL) { @@ -3002,14 +2902,22 @@ void StartMoving(int x, int y) EL_BD_MAGIC_WALL_FILLING); Store[x][y] = element; } +#if 0 else if (CAN_SMASH(element) && Feld[x][y+1] == EL_ACID) +#else + else if (CAN_FALL(element) && Feld[x][y+1] == EL_ACID) +#endif { - Blurb(x, y); + SplashAcid(x, y); InitMovingField(x, y, MV_DOWN); started_moving = TRUE; Store[x][y] = EL_ACID; +#if 0 + /* !!! TEST !!! better use "_FALLING" etc. !!! */ + GfxAction[x][y+1] = ACTION_ACTIVE; +#endif } else if (CAN_SMASH(element) && Feld[x][y+1] == EL_BLOCKED && JustStopped[x][y]) @@ -3026,12 +2934,15 @@ void StartMoving(int x, int y) } else if (IS_FREE(x, y+1)) { + if (JustStopped[x][y]) /* prevent animation from being restarted */ + MovDir[x][y] = MV_DOWN; + InitMovingField(x, y, MV_DOWN); started_moving = TRUE; } else if (element == EL_AMOEBA_DROP) { - Feld[x][y] = EL_AMOEBA_CREATING; + Feld[x][y] = EL_AMOEBA_GROWING; Store[x][y] = EL_AMOEBA_WET; } /* Store[x][y+1] must be zero, because: @@ -3081,7 +2992,7 @@ void StartMoving(int x, int y) InitMovingField(x, y, belt_dir); started_moving = TRUE; - GfxAction[x][y] = GFX_ACTION_DEFAULT; + GfxAction[x][y] = ACTION_DEFAULT; } } } @@ -3120,15 +3031,8 @@ void StartMoving(int x, int y) element != EL_DARK_YAMYAM && element != EL_PACMAN) { -#if 0 - if (element == EL_SPRING) - printf("1--> %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 || @@ -3143,36 +3047,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++) @@ -3209,7 +3101,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; } @@ -3239,7 +3131,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)) @@ -3249,7 +3141,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_CLASS_EXIT_PASSING); if (IN_SCR_FIELD(SCREENX(newx), SCREENY(newy))) DrawGraphicThruMask(SCREENX(newx),SCREENY(newy), el2img(element), 0); @@ -3288,7 +3180,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)) { @@ -3352,7 +3244,7 @@ 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])) @@ -3373,7 +3265,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])) @@ -3389,7 +3281,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 */ } @@ -3397,7 +3289,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) && @@ -3420,23 +3312,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]) @@ -3453,7 +3345,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) @@ -3545,7 +3437,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]; @@ -3559,9 +3451,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; @@ -3574,6 +3471,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); @@ -3597,15 +3495,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); } } @@ -3772,7 +3661,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; @@ -3800,10 +3689,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; } } @@ -3813,10 +3706,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]) @@ -3868,6 +3761,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] = { @@ -3884,6 +3778,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)); @@ -3989,18 +3886,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; @@ -4015,8 +3916,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; @@ -4046,7 +3951,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++; @@ -4068,7 +3973,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; @@ -4078,311 +3983,72 @@ 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); } -void RobotWheel(int x, int y) +static void InitRobotWheel(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; - } - } + MovDelay[x][y] = level.time_wheel * FRAMES_PER_SECOND; +} - Feld[x][y] = EL_ROBOT_WHEEL; - DrawLevelField(x, y); +static void RunRobotWheel(int x, int y) +{ + PlaySoundLevel(x, y, SND_ROBOT_WHEEL_ACTIVE); +} +static void StopRobotWheel(int x, int y) +{ if (ZX == x && ZY == y) ZX = ZY = -1; } -void TimegateWheel(int x, int y) +static void InitTimegateWheel(int x, int y) { - if (!MovDelay[x][y]) /* next animation frame */ - MovDelay[x][y] = level.time_wheel * FRAMES_PER_SECOND; + 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_TIMEGATE_SWITCH_ACTIVE, -1); +static void RunTimegateWheel(int x, int y) +{ + PlaySoundLevel(x, y, SND_TIMEGATE_SWITCH_ACTIVE); +} - DrawGraphic(SCREENX(x), SCREENY(y), IMG_TIMEGATE_SWITCH_ACTIVE, frame); - } +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) + { + 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 LOOKS WRONG !!! */ - if (ZX == x && ZY == y) - ZX = ZY = -1; + PlaySoundLevelNearest(x, y, SND_CLASS_EXIT_OPENING); } -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); -} - -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); -} - -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 AusgangstuerPruefen(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; - - PlaySoundLevel(x < LEVELX(BX1) ? LEVELX(BX1) : - (x > LEVELX(BX2) ? LEVELX(BX2) : x), - y < LEVELY(BY1) ? LEVELY(BY1) : - (y > LEVELY(BY2) ? LEVELY(BY2) : y), - SND_EXIT_OPENING); -} - -void AusgangstuerPruefen_SP(int x, int y) +void CheckExitSP(int x, int y) { if (local_player->gems_still_needed > 0) - return; - - Feld[x][y] = EL_SP_EXIT_OPEN; - - PlaySoundLevel(x < LEVELX(BX1) ? LEVELX(BX1) : - (x > LEVELX(BX2) ? LEVELX(BX2) : x), - y < LEVELY(BY1) ? LEVELY(BY1) : - (y > LEVELY(BY2) ? LEVELY(BY2) : y), - SND_SP_EXIT_OPENING); -} - -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); -} - -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); -} - -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); -} - -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); -} - -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); } static void CloseAllOpenTimegates() @@ -4398,7 +4064,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 } } } @@ -4410,43 +4080,37 @@ void EdelsteinFunkeln(int x, int y) return; if (Feld[x][y] == EL_BD_DIAMOND) - DrawLevelElementAnimation(x, y, el2img(Feld[x][y])); - else - { - if (!MovDelay[x][y]) /* next animation frame */ - MovDelay[x][y] = 11 * !SimpleRND(500); + return; - if (MovDelay[x][y]) /* 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]) - { - 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); } } } @@ -4505,12 +4169,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; @@ -4530,57 +4198,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])) @@ -4593,13 +4263,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) @@ -4689,139 +4364,24 @@ static void WarnBuggyBase(int x, int y) } } -static void CheckBuggyBase(int x, int y) +static void InitTrap(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); - } - } + MovDelay[x][y] = 2 * FRAMES_PER_SECOND + RND(5 * FRAMES_PER_SECOND); } -static void CheckTrap(int x, int y) +static void ActivateTrap(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]--; - - if (MovDelay[x][y] != 0) - { - if (DrawLevelElementAnimation(x, y, element)) - DrawCrumbledSand(SCREENX(x), SCREENY(y)); - } - else - { - Feld[x][y] = EL_TRAP; - DrawLevelField(x, y); - } - } + PlaySoundLevel(x, y, SND_TRAP_ACTIVATING); } -#if 0 -static void DrawBeltAnimation(int x, int y, int element) +static void ChangeActiveTrap(int x, int y) { - int belt_nr = getBeltNrFromBeltActiveElement(element); - int belt_dir = game.belt_dir[belt_nr]; + int graphic = IMG_TRAP_ACTIVE; - if (belt_dir != MV_NO_MOVING) - { - DrawLevelElementAnimation(x, y, element); - - if (!(FrameCounter % 2)) - PlaySoundLevelAction(x, y, SND_ACTION_ACTIVE); - } + /* if new animation frame was drawn, correct crumbled sand border */ + if (IS_NEW_FRAME(GfxFrame[x][y], graphic)) + DrawCrumbledSand(SCREENX(x), SCREENY(y)); } -#endif static void ChangeElement(int x, int y) { @@ -4830,7 +4390,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); @@ -4840,7 +4402,8 @@ static void ChangeElement(int x, int y) if (MovDelay[x][y] != 0) /* continue element change */ { - DrawLevelElementAnimation(x, y, element); + if (IS_ANIMATED(el2img(element))) + DrawLevelElementAnimationIfNeeded(x, y, element); if (changing_element[element].change_function) changing_element[element].change_function(x, y); @@ -4848,6 +4411,10 @@ static void ChangeElement(int x, int y) else /* finish element change */ { Feld[x][y] = changing_element[element].next_element; + + ResetGfxAnimation(x, y); + ResetRandomAnimationValue(x, y); + DrawLevelField(x, y); if (changing_element[element].post_change_function) @@ -4859,9 +4426,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; @@ -4880,11 +4444,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 @@ -4903,20 +4462,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 { @@ -4926,81 +4472,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; @@ -5084,30 +4580,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; i 1) - DrawLevelGraphicAnimation(x, y, graphic); + PlaySoundLevelActionIfLoop(x, y, GfxAction[x][y]); #endif + if (IS_INACTIVE(element)) + { + if (IS_ANIMATED(graphic)) + DrawLevelGraphicAnimationIfNeeded(x, y, graphic); + continue; } @@ -5153,18 +4643,14 @@ void GameActions() { StartMoving(x, y); -#if 1 - if (Feld[x][y] == EL_EMERALD && - new_graphic_info[graphic].anim_frames > 1 && - !IS_MOVING(x, y)) - DrawLevelGraphicAnimation(x, y, graphic); -#endif + if (IS_ANIMATED(graphic) && + !IS_MOVING(x, y) && + !Stop[x][y]) + DrawLevelGraphicAnimationIfNeeded(x, y, graphic); if (IS_GEM(element) || element == EL_SP_INFOTRON) EdelsteinFunkeln(x, y); } - -#if 1 else if ((element == EL_ACID || element == EL_EXIT_OPEN || element == EL_SP_EXIT_OPEN || @@ -5173,10 +4659,8 @@ void GameActions() element == EL_EXTRA_TIME || element == EL_SHIELD_NORMAL || element == EL_SHIELD_DEADLY) && - new_graphic_info[graphic].anim_frames > 1) - DrawLevelGraphicAnimation(x, y, graphic); -#endif - + IS_ANIMATED(graphic)) + DrawLevelGraphicAnimationIfNeeded(x, y, graphic); else if (IS_MOVING(x, y)) ContinueMoving(x, y); else if (IS_ACTIVE_BOMB(element)) @@ -5185,7 +4669,7 @@ void GameActions() else if (element == EL_EXPLOSION && !game.explosions_delayed) Explode(x, y, ExplodePhase[x][y], EX_NORMAL); #endif - else if (element == EL_AMOEBA_CREATING) + else if (element == EL_AMOEBA_GROWING) AmoebeWaechst(x, y); else if (element == EL_AMOEBA_SHRINKING) AmoebaDisappearing(x, y); @@ -5195,93 +4679,46 @@ void GameActions() AmoebeAbleger(x, y); #endif - else if (element == EL_GAMEOFLIFE || element == EL_BIOMAZE) + else if (element == EL_GAME_OF_LIFE || element == EL_BIOMAZE) Life(x, y); - else if (element == EL_ROBOT_WHEEL_ACTIVE) - RobotWheel(x, y); - else if (element == EL_TIMEGATE_SWITCH_ACTIVE) - TimegateWheel(x, y); - else if (element == EL_ACID_SPLASH_LEFT || - element == EL_ACID_SPLASH_RIGHT) - Blurb(x, y); -#if 0 - else if (element == EL_NUT_CRACKING) - NussKnacken(x, y); - else if (element == EL_PEARL_BREAKING) - BreakingPearl(x, y); -#endif else if (element == EL_EXIT_CLOSED) - AusgangstuerPruefen(x, y); + CheckExit(x, y); else if (element == EL_SP_EXIT_CLOSED) - AusgangstuerPruefen_SP(x, y); -#if 0 - else if (element == EL_EXIT_OPENING) - AusgangstuerOeffnen(x, y); -#endif - else if (element == EL_WALL_GROWING_ACTIVE) + CheckExitSP(x, y); + else if (element == EL_EXPANDABLE_WALL_GROWING) MauerWaechst(x, y); - else if (element == EL_WALL_GROWING || - element == EL_WALL_GROWING_X || - element == EL_WALL_GROWING_Y || - element == EL_WALL_GROWING_XY) + else if (element == EL_EXPANDABLE_WALL || + element == EL_EXPANDABLE_WALL_HORIZONTAL || + element == EL_EXPANDABLE_WALL_VERTICAL || + element == EL_EXPANDABLE_WALL_ANY) MauerAbleger(x, y); else if (element == EL_FLAMES) CheckForDragon(x, y); - else if (element == EL_SP_BUGGY_BASE || - element == EL_SP_BUGGY_BASE_ACTIVATING || - element == EL_SP_BUGGY_BASE_ACTIVE) - CheckBuggyBase(x, y); - else if (element == EL_TRAP || element == EL_TRAP_ACTIVE) - CheckTrap(x, y); -#if 0 - else if (IS_BELT_ACTIVE(element)) - DrawBeltAnimation(x, y, element); - else if (element == EL_SWITCHGATE_OPENING) - OpenSwitchgate(x, y); - else if (element == EL_SWITCHGATE_CLOSING) - CloseSwitchgate(x, y); - else if (element == EL_TIMEGATE_OPENING) - OpenTimegate(x, y); - else if (element == EL_TIMEGATE_CLOSING) - CloseTimegate(x, y); -#endif - else if (IS_AUTO_CHANGING(element)) ChangeElement(x, y); - -#if 1 - else if (new_graphic_info[graphic].anim_frames > 1) - DrawLevelGraphicAnimation(x, y, graphic); -#endif + else if (element == EL_EXPLOSION) + ; /* drawing of correct explosion animation is handled separately */ + else if (IS_ANIMATED(graphic)) + DrawLevelGraphicAnimationIfNeeded(x, y, graphic); if (IS_BELT_ACTIVE(element)) - PlaySoundLevelAction(x, y, SND_ACTION_ACTIVE); + PlaySoundLevelAction(x, y, ACTION_ACTIVE); if (game.magic_wall_active) { - boolean sieb = FALSE; int jx = local_player->jx, 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; } } } @@ -5349,14 +4786,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) @@ -5444,14 +4881,14 @@ void GameActions() if (TimeLeft <= 10 && setup.time_limit) PlaySoundStereo(SND_GAME_RUNNING_OUT_OF_TIME, SOUND_MAX_RIGHT); - 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; iPushing) - 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) { @@ -5821,8 +5287,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; @@ -5835,7 +5299,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; @@ -6116,8 +5579,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; @@ -6160,7 +5623,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; @@ -6200,6 +5663,9 @@ int DigField(struct PlayerInfo *player, dy == +1 ? MV_DOWN : MV_NO_MOVING); int element; + if (player->MovPos == 0) + player->is_digging = FALSE; + if (player->MovPos == 0) player->Pushing = FALSE; @@ -6218,7 +5684,7 @@ int DigField(struct PlayerInfo *player, 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 }, @@ -6255,8 +5721,12 @@ int DigField(struct PlayerInfo *player, case EL_SP_BASE: case EL_SP_BUGGY_BASE: case EL_SP_BUGGY_BASE_ACTIVATING: +#if 1 + if (mode != DF_SNAP && element == EL_SAND) + GfxElement[x][y] = Feld[x][y]; +#endif RemoveField(x, y); - PlaySoundLevelElementAction(x, y, element, SND_ACTION_DIGGING); + PlaySoundLevelElementAction(x, y, element, ACTION_DIGGING); break; case EL_EMERALD: @@ -6276,9 +5746,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: @@ -6297,7 +5766,7 @@ 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); break; @@ -6319,68 +5788,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; } @@ -6414,23 +5885,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; @@ -6441,7 +5912,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; @@ -6466,20 +5937,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; @@ -6495,7 +5966,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) @@ -6516,7 +5989,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) && @@ -6545,30 +6019,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; @@ -6577,14 +6051,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; @@ -6593,7 +6067,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: @@ -6605,40 +6083,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_GRAVITY_PORT_LEFT: + case EL_SP_PORT_RIGHT: + case EL_SP_GRAVITY_PORT_RIGHT: + case EL_SP_PORT_UP: + case EL_SP_GRAVITY_PORT_UP: + case EL_SP_PORT_DOWN: + case EL_SP_GRAVITY_PORT_DOWN: + case EL_SP_PORT_HORIZONTAL: + case EL_SP_PORT_VERTICAL: + case EL_SP_PORT_ANY: 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; @@ -6647,10 +6125,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: @@ -6665,7 +6143,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 }, @@ -6689,7 +6167,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; @@ -6705,9 +6183,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; @@ -6722,7 +6200,7 @@ 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); return MF_ACTION; @@ -6786,24 +6264,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); @@ -6816,7 +6310,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; @@ -6827,11 +6321,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 something */ + player->is_digging = TRUE; + return MF_MOVING; } @@ -6852,6 +6391,10 @@ boolean SnapField(struct PlayerInfo *player, int dx, int dy) player->Pushing = FALSE; player->snapped = FALSE; + + if (player->MovPos == 0) + player->is_digging = FALSE; + return FALSE; } @@ -6867,6 +6410,7 @@ boolean SnapField(struct PlayerInfo *player, int dx, int dy) return FALSE; player->snapped = TRUE; + player->is_digging = FALSE; DrawLevelField(x, y); BackToFront(); @@ -6890,42 +6434,71 @@ boolean PlaceBomb(struct PlayerInfo *player) if (element != EL_EMPTY) Store[jx][jy] = element; + MovDelay[jx][jy] = 96; + + ResetGfxAnimation(jx, jy); + ResetRandomAnimationValue(jx, jy); + if (player->dynamite) { - Feld[jx][jy] = EL_DYNAMITE_ACTIVE; - MovDelay[jx][jy] = 96; + 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); - MovDelay[jx][jy] = 96; + 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; } -void PlaySoundLevel(int x, int y, int nr) +/* ------------------------------------------------------------------------- */ +/* 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; @@ -6969,24 +6542,48 @@ void PlaySoundLevel(int x, int y, int nr) PlaySoundExt(nr, volume, stereo_position, type); } -void PlaySoundLevelAction(int x, int y, int sound_action) +static void PlaySoundLevelNearest(int x, int y, int sound_action) { - PlaySoundLevelElementAction(x, y, Feld[x][y], sound_action); + PlaySoundLevel(x < LEVELX(BX1) ? LEVELX(BX1) : + x > LEVELX(BX2) ? LEVELX(BX2) : x, + y < LEVELY(BY1) ? LEVELY(BY1) : + y > LEVELY(BY2) ? LEVELY(BY2) : y, + 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) +{ + int sound_effect = element_info[element].sound[action]; + + if (sound_effect != SND_UNDEFINED) + PlaySoundLevel(x, y, sound_effect); } -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) @@ -7027,10 +6624,10 @@ void RaiseScoreElement(int element) case EL_DYNAMITE: RaiseScore(level.score[SC_DYNAMIT]); 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: RaiseScore(level.score[SC_SCHLUESSEL]); break; default: @@ -7125,7 +6722,7 @@ void CreateGameButtons() for (i=0; i