#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
#define NUM_GAME_BUTTONS 6
/* forward declaration for internal use */
+static void ResetGfxAnimation(int, int);
+
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 MapGameButtons();
static void HandleGameButtons(struct GadgetInfo *);
/* ------------------------------------------------------------------------- */
-/* 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
{
int base_element;
int next_element;
int change_delay;
- void (*changer_function)(int x, int y);
+ void (*pre_change_function)(int x, int y);
+ void (*change_function)(int x, int y);
+ void (*post_change_function)(int x, int y);
};
static struct ChangingElementInfo changing_element_list[] =
{
- { EL_NUT_CRACKING, EL_EMERALD, 6, NULL },
- { EL_PEARL_BREAKING, EL_EMPTY, 8, NULL },
- { EL_UNDEFINED, EL_UNDEFINED, -1, NULL }
-};
+ { EL_NUT_CRACKING, 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 },
-static struct ChangingElementInfo changing_element[MAX_NUM_ELEMENTS];
+ { EL_SWITCHGATE_OPENING, EL_SWITCHGATE_OPEN, 29, NULL, NULL, NULL },
+ { EL_SWITCHGATE_CLOSING, EL_SWITCHGATE_CLOSED, 29, NULL, NULL, NULL },
-#define IS_AUTO_CHANGING(e) (changing_element[e].base_element != EL_UNDEFINED)
+ { 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,
+ InitBuggyBase, NULL, NULL },
+ { EL_SP_BUGGY_BASE_ACTIVE, EL_SP_BUGGY_BASE, 0,
+ InitBuggyBase, WarnBuggyBase, NULL },
-#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; y<lev_fieldy; y++) for(x=0; x<lev_fieldx; x++)
- {
- /*
- if (counter == 3)
- {
- if (first_game)
- lastFeld[x][y] = Feld[x][y];
- else if (lastFeld[x][y] != Feld[x][y])
- printf("DIFF: [%d][%d]: lastFeld == %d != %d == Feld\n",
- x, y, lastFeld[x][y], Feld[x][y]);
- }
- */
-
- checksum += mult++ * Ur[x][y];
- checksum += mult++ * Feld[x][y];
+ { EL_TRAP, EL_TRAP_ACTIVE, 0,
+ InitTrap, NULL, ActivateTrap },
+ { EL_TRAP_ACTIVE, EL_TRAP, 31,
+ NULL, ChangeActiveTrap, NULL },
- /*
- checksum += mult++ * MovPos[x][y];
- checksum += mult++ * MovDir[x][y];
- checksum += mult++ * MovDelay[x][y];
- checksum += mult++ * Store[x][y];
- checksum += mult++ * Store2[x][y];
- checksum += mult++ * StorePlayer[x][y];
- checksum += mult++ * ExplodePhase[x][y];
- checksum += mult++ * AmoebaNr[x][y];
- checksum += mult++ * JustStopped[x][y];
- checksum += mult++ * Stop[x][y];
- */
- }
+ { EL_ROBOT_WHEEL_ACTIVE, EL_ROBOT_WHEEL, 0,
+ InitRobotWheel, RunRobotWheel, StopRobotWheel },
- if (counter == 3 && first_game)
- first_game = FALSE;
+ { EL_TIMEGATE_SWITCH_ACTIVE, EL_TIMEGATE_SWITCH, 0,
+ InitTimegateWheel, RunTimegateWheel, NULL },
- return checksum;
-}
-#endif
-#endif
+ { 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)
void GetPlayerConfig()
}
-/*
- =============================================================================
- 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<MAX_NUM_ELEMENTS; i++)
- for (j=0; j<NUM_SND_ACTIONS; j++)
- element_action_sound[i][j] = -1;
-
- for (i=0; i<NUM_SOUND_FILES; i++)
- {
- int len_effect_text = strlen(sound_files[i].token);
-
- sound_effect_properties[i] = SND_ACTION_UNKNOWN;
- is_loop_sound[i] = FALSE;
-
- /* determine all loop sounds and identify certain sound classes */
-
- for (j=0; sound_action_properties[j].text; j++)
- {
- int len_action_text = strlen(sound_action_properties[j].text);
-
- if (len_action_text < len_effect_text &&
- strcmp(&sound_files[i].token[len_effect_text - len_action_text],
- sound_action_properties[j].text) == 0)
- {
- sound_effect_properties[i] = sound_action_properties[j].value;
-
- if (sound_action_properties[j].is_loop)
- is_loop_sound[i] = TRUE;
- }
- }
-
- /* associate elements and some selected sound actions */
-
- for (j=0; j<MAX_NUM_ELEMENTS; j++)
- {
- if (element_info[j].sound_class_name)
- {
- int len_class_text = strlen(element_info[j].sound_class_name);
-
- if (len_class_text + 1 < len_effect_text &&
- strncmp(sound_files[i].token,
- element_info[j].sound_class_name, len_class_text) == 0 &&
- sound_files[i].token[len_class_text] == '.')
- {
- int sound_action_value = sound_effect_properties[i];
-
- element_action_sound[j][sound_action_value] = i;
- }
- }
- }
- }
-
-#if 0
- debug_print_timestamp(0, "InitGameEngine");
-#endif
-
-#if 0
- /* TEST ONLY */
- {
- int element = EL_SAND;
- int sound_action = SND_ACTION_DIGGING;
- int j = 0;
-
- while (sound_action_properties[j].text)
- {
- if (sound_action_properties[j].value == sound_action)
- printf("element %d, sound action '%s' == %d\n",
- element, sound_action_properties[j].text,
- element_action_sound[element][sound_action]);
- j++;
- }
- }
-#endif
-}
-
-
/*
=============================================================================
InitGameEngine()
changing_element[i].base_element = EL_UNDEFINED;
changing_element[i].next_element = EL_UNDEFINED;
changing_element[i].change_delay = -1;
- changing_element[i].changer_function = NULL;
+ changing_element[i].pre_change_function = NULL;
+ changing_element[i].change_function = NULL;
+ changing_element[i].post_change_function = NULL;
}
i = 0;
struct ChangingElementInfo *ce = &changing_element_list[i];
int element = ce->base_element;
- changing_element[element].base_element = ce->base_element;
- changing_element[element].next_element = ce->next_element;
- changing_element[element].change_delay = ce->change_delay;
- changing_element[element].changer_function = ce->changer_function;
+ changing_element[element].base_element = ce->base_element;
+ changing_element[element].next_element = ce->next_element;
+ changing_element[element].change_delay = ce->change_delay;
+ changing_element[element].pre_change_function = ce->pre_change_function;
+ changing_element[element].change_function = ce->change_function;
+ changing_element[element].post_change_function = ce->post_change_function;
i++;
}
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();
}
}
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)
return position;
}
+static void ResetRandomAnimationValue(int x, int y)
+{
+ int element = Feld[x][y];
+ int graphic = el2img(element);
+
+ /* reset random value not until one full delay cycle has reached */
+ if (ANIM_MODE(graphic) == ANIM_RANDOM &&
+ GfxFrame[x][y] > ANIM_DELAY(graphic))
+ GfxRandom[x][y] = INIT_GFX_RANDOM();
+}
+
+static void ResetGfxAnimation(int x, int y)
+{
+ ResetRandomAnimationValue(x, y);
+
+ GfxFrame[x][y] = 0;
+ GfxAction[x][y] = ACTION_DEFAULT;
+
+#if 0
+ if (Feld[x][y] == EL_ROCK)
+ printf("ResetGfxAnimation: EL_ROCK [%d, %d]\n",
+ JustStopped[x][y], MovDir[x][y]);
+#endif
+}
+
void InitMovingField(int x, int y, int direction)
{
int element = Feld[x][y];
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)
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);
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 (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
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] != 0)
+ {
+ DrawDynamite(x, y);
- if (!(MovDelay[x][y] % delay))
- DrawDynamite(x, y);
- }
+ /* !!! correct: "PlaySoundLevelActionIfLoop" etc. !!! */
+ PlaySoundLevelAction(x, y, ACTION_ACTIVE);
return;
}
}
}
-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;
- }
}
+
+#if 0
else /* go on */
{
int graphic = (element == EL_ACID_SPLASH_LEFT ?
}
}
}
+#endif
}
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;
}
}
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<lev_fieldy; yy++)
return;
object_hit = (!IS_FREE(x, y+1) && (!IS_MOVING(x, y+1) ||
- MovDir[x][y+1]!=MV_DOWN ||
- MovPos[x][y+1]<=TILEY/2));
+ MovDir[x][y+1] != MV_DOWN ||
+ MovPos[x][y+1] <= TILEY / 2));
if (object_hit)
smashed = MovingOrBlocked2Element(x, y+1);
}
if (!lastline && smashed == EL_ACID) /* element falls into acid */
{
- Blurb(x, y);
+ SplashAcid(x, y);
return;
}
+#if 1
+ if (lastline || object_hit)
+ {
+#if 0
+ MovDir[x][y] = 0;
+#endif
+ ResetGfxAnimation(x, y);
+ DrawLevelField(x, y);
+ }
+#endif
+
if ((element == EL_BOMB ||
element == EL_SP_DISK_ORANGE ||
element == EL_DX_SUPABOMB) &&
- (lastline || object_hit)) /* element is bomb */
+ (lastline || object_hit)) /* element is bomb */
{
Bang(x, y);
return;
if (!lastline && object_hit) /* check which object was hit */
{
if (CAN_CHANGE(element) &&
- (smashed == EL_MAGIC_WALL || smashed == EL_BD_MAGIC_WALL))
+ (smashed == EL_MAGIC_WALL ||
+ smashed == EL_BD_MAGIC_WALL))
{
int xx, yy;
int activated_magic_wall =
SND_BD_MAGIC_WALL_ACTIVATING));
}
- if (IS_PLAYER(x, y+1))
+ if (IS_PLAYER(x, y + 1))
{
KillHeroUnlessProtected(x, y+1);
return;
}
else if (smashed == EL_PENGUIN)
{
- Bang(x, y+1);
+ Bang(x, y + 1);
return;
}
else if (element == EL_BD_DIAMOND)
{
if (IS_ENEMY(smashed) && IS_BD_ELEMENT(smashed))
{
- Bang(x, y+1);
+ Bang(x, y + 1);
return;
}
}
- else if ((element == EL_SP_INFOTRON || element == EL_SP_ZONK) &&
- (smashed == EL_SP_SNIKSNAK || smashed == EL_SP_ELECTRON ||
+ else if ((element == EL_SP_INFOTRON ||
+ element == EL_SP_ZONK) &&
+ (smashed == EL_SP_SNIKSNAK ||
+ smashed == EL_SP_ELECTRON ||
smashed == EL_SP_DISK_ORANGE))
{
- Bang(x, y+1);
+ Bang(x, y + 1);
return;
}
else if (element == EL_ROCK ||
element == EL_BD_ROCK)
{
if (IS_ENEMY(smashed) ||
- smashed == EL_BOMB || smashed == EL_SP_DISK_ORANGE ||
+ smashed == EL_BOMB ||
+ smashed == EL_SP_DISK_ORANGE ||
smashed == EL_DX_SUPABOMB ||
- smashed == EL_SATELLITE || smashed == EL_PIG ||
- smashed == EL_DRAGON || smashed == EL_MOLE)
+ smashed == EL_SATELLITE ||
+ smashed == EL_PIG ||
+ smashed == EL_DRAGON ||
+ smashed == EL_MOLE)
{
- Bang(x, y+1);
+ Bang(x, y + 1);
return;
}
- else if (!IS_MOVING(x, y+1))
+ else if (!IS_MOVING(x, y + 1))
{
- if (smashed == EL_LAMP || smashed == EL_LAMP_ACTIVE)
+ if (smashed == EL_LAMP ||
+ smashed == EL_LAMP_ACTIVE)
{
- Bang(x, y+1);
+ Bang(x, y + 1);
return;
}
else if (smashed == EL_NUT)
/* play sound of object that hits the ground */
if (lastline || object_hit)
- PlaySoundLevelElementAction(x, y, element, SND_ACTION_IMPACT);
+ PlaySoundLevelElementAction(x, y, element, ACTION_IMPACT);
}
void TurnRound(int x, int y)
}
}
- if (element == EL_ROBOT && ZX>=0 && ZY>=0)
+ if (element == EL_ROBOT && ZX >= 0 && ZY >= 0)
{
attr_x = ZX;
attr_y = ZY;
if (Stop[x][y])
return;
- GfxAction[x][y] = GFX_ACTION_DEFAULT;
+ GfxAction[x][y] = ACTION_DEFAULT;
if (CAN_FALL(element) && y < lev_fieldy - 1)
{
}
else if (CAN_SMASH(element) && Feld[x][y+1] == EL_ACID)
{
- Blurb(x, y);
+ SplashAcid(x, y);
InitMovingField(x, y, MV_DOWN);
started_moving = TRUE;
}
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;
}
InitMovingField(x, y, belt_dir);
started_moving = TRUE;
- GfxAction[x][y] = GFX_ACTION_DEFAULT;
+ GfxAction[x][y] = ACTION_DEFAULT;
}
}
}
MovDelay[x][y]--;
if (element == EL_ROBOT ||
- element == EL_YAMYAM || element == EL_DARK_YAMYAM)
+ element == EL_YAMYAM ||
+ element == EL_DARK_YAMYAM)
{
+#if 1
+ DrawLevelElementAnimationIfNeeded(x, y, element);
+#else
if (IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
{
int graphic = el2img(element);
DrawGraphic(SCREENX(x), SCREENY(y), graphic, frame);
}
+#endif
+#if 1
+ PlaySoundLevelAction(x, y, ACTION_WAITING);
+#else
if (MovDelay[x][y] % 4 == 3)
{
if (element == EL_YAMYAM)
else if (element == EL_DARK_YAMYAM)
PlaySoundLevel(x, y, SND_DARK_YAMYAM_WAITING);
}
+#endif
}
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_FLAMES1_LEFT :
+ dir == MV_RIGHT ? IMG_FLAMES1_RIGHT :
+ dir == MV_UP ? IMG_FLAMES1_UP :
+ dir == MV_DOWN ? IMG_FLAMES1_DOWN : IMG_EMPTY);
int frame = getGraphicAnimationFrame(graphic, -1);
for (i=1; i<=3; i++)
if (MovDelay[x][y]) /* element still has to wait some time */
{
- PlaySoundLevelAction(x, y, SND_ACTION_WAITING);
+ PlaySoundLevelAction(x, y, ACTION_WAITING);
return;
}
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))
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])
MovPos[x][y] = MovDir[x][y] = MovDelay[x][y] = 0;
MovDelay[newx][newy] = 0;
+#if 0
+ /* all done in "InitMovingField()" */
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 */
+#endif
+
+ /* copy animation control values to new field */
+ GfxFrame[newx][newy] = GfxFrame[x][y];
+ GfxAction[newx][newy] = GfxAction[x][y];
+ GfxRandom[newx][newy] = GfxRandom[x][y];
+
+ ResetGfxAnimation(x, y); /* reset animation values for old field */
+#if 1
#if 0
if (!CAN_MOVE(element))
MovDir[newx][newy] = 0;
if (!CAN_MOVE(element) ||
(element == EL_SPRING && MovDir[newx][newy] == MV_DOWN))
MovDir[newx][newy] = 0;
+#endif
#endif
DrawLevelField(x, y);
else /* still moving on */
{
#if 0
- if (GfxAction[x][y] == GFX_ACTION_DEFAULT)
+ if (GfxAction[x][y] == ACTION_DEFAULT)
{
printf("reset GfxAction...\n");
- GfxAction[x][y] = GFX_ACTION_MOVING;
+ GfxAction[x][y] = ACTION_MOVING;
}
#endif
SND_BIOMAZE_CREATING);
}
-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;
- }
- }
-
- Feld[x][y] = EL_ROBOT_WHEEL;
- DrawLevelField(x, y);
-
- if (ZX == x && ZY == y)
- ZX = ZY = -1;
+ MovDelay[x][y] = level.time_wheel * FRAMES_PER_SECOND;
}
-void TimegateWheel(int x, int y)
+static void RunRobotWheel(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_TIMEGATE_SWITCH_ACTIVE, -1);
-
- DrawGraphic(SCREENX(x), SCREENY(y), IMG_TIMEGATE_SWITCH_ACTIVE, frame);
- }
-
- PlaySoundLevel(x, y, SND_TIMEGATE_SWITCH_ACTIVE);
-
- return;
- }
- }
-
- Feld[x][y] = EL_TIMEGATE_SWITCH;
- DrawLevelField(x, y);
-
- /* !!! THIS LOOKS WRONG !!! */
- if (ZX == x && ZY == y)
- ZX = ZY = -1;
+ PlaySoundLevel(x, y, SND_ROBOT_WHEEL_ACTIVE);
}
-void NussKnacken(int x, int y)
+static void StopRobotWheel(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);
+ if (ZX == x && ZY == y)
+ ZX = ZY = -1;
}
-void BreakingPearl(int x, int y)
+static void InitTimegateWheel(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);
+ MovDelay[x][y] = level.time_wheel * FRAMES_PER_SECOND;
}
-void SiebAktivieren(int x, int y, int type)
+static void RunTimegateWheel(int x, int y)
{
- int graphic = (type == 1 ? IMG_MAGIC_WALL_FULL : IMG_BD_MAGIC_WALL_FULL);
-
- DrawLevelGraphicAnimation(x, y, graphic);
+ PlaySoundLevel(x, y, SND_TIMEGATE_SWITCH_ACTIVE);
}
-void AusgangstuerPruefen(int x, int y)
+void CheckExit(int x, int y)
{
if (local_player->gems_still_needed > 0 ||
local_player->sokobanfields_still_needed > 0 ||
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);
+ PlaySoundLevelNearest(x, 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]);
-
- DrawGraphic(SCREENX(x), SCREENY(y), IMG_TIMEGATE_OPENING, frame);
- }
- }
-
- if (MovDelay[x][y])
- 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_TIMEGATE_CLOSED;
- DrawLevelField(x, y);
+ PlaySoundLevelNearest(x, y, SND_SP_EXIT_OPENING);
}
static void CloseAllOpenTimegates()
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]) /* next animation frame */
+ if (MovDelay[x][y] == 0) /* next animation frame */
MovDelay[x][y] = 11 * !SimpleRND(500);
- if (MovDelay[x][y]) /* wait some time before next frame */
+ if (MovDelay[x][y] != 0) /* wait some time before next frame */
{
MovDelay[x][y]--;
DrawLevelElementAnimation(x, y, Feld[x][y]);
#endif
- if (MovDelay[x][y])
+ if (MovDelay[x][y] != 0)
{
int frame = getGraphicAnimationFrame(IMG_TWINKLE_WHITE,
10 - MovDelay[x][y]);
}
}
-static void CheckBuggyBase(int x, int y)
+static void InitBuggyBase(int x, int y)
{
int element = Feld[x][y];
+ int activating_delay = FRAMES_PER_SECOND / 4;
+
+ MovDelay[x][y] =
+ (element == EL_SP_BUGGY_BASE ?
+ 2 * FRAMES_PER_SECOND + RND(5 * FRAMES_PER_SECOND) - activating_delay :
+ element == EL_SP_BUGGY_BASE_ACTIVATING ?
+ activating_delay :
+ element == EL_SP_BUGGY_BASE_ACTIVE ?
+ 1 * FRAMES_PER_SECOND + RND(1 * FRAMES_PER_SECOND) : 1);
+}
- if (element == EL_SP_BUGGY_BASE)
+static void WarnBuggyBase(int x, int y)
+{
+ int i;
+ static int xy[4][2] =
{
- if (!MovDelay[x][y]) /* wait some time before activating base */
- MovDelay[x][y] = 2 * FRAMES_PER_SECOND + RND(5 * FRAMES_PER_SECOND);
-
- if (MovDelay[x][y])
- {
- MovDelay[x][y]--;
- if (MovDelay[x][y] < 5 && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
- DrawGraphic(SCREENX(x), SCREENY(y), IMG_SP_BUGGY_BASE, 0);
- if (MovDelay[x][y])
- return;
+ { 0, -1 },
+ { -1, 0 },
+ { +1, 0 },
+ { 0, +1 }
+ };
- Feld[x][y] = EL_SP_BUGGY_BASE_ACTIVE;
- }
- }
- else if (element == EL_SP_BUGGY_BASE_ACTIVE)
+ for (i=0; i<4; i++)
{
- if (!MovDelay[x][y]) /* start activating buggy base */
- MovDelay[x][y] = 1 * FRAMES_PER_SECOND + RND(1 * FRAMES_PER_SECOND);
+ int xx = x + xy[i][0], yy = y + xy[i][1];
- if (MovDelay[x][y])
+ if (IS_PLAYER(xx, yy))
{
- MovDelay[x][y]--;
- if (MovDelay[x][y])
- {
- int i;
- static int xy[4][2] =
- {
- { 0, -1 },
- { -1, 0 },
- { +1, 0 },
- { 0, +1 }
- };
-
- if (IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
- {
- int graphic = IMG_SP_BUGGY_BASE_ACTIVE;
- int frame = getGraphicAnimationFrame(graphic, SimpleRND(100));
-
- DrawGraphic(SCREENX(x), SCREENY(y), graphic, frame);
- }
-
- 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;
- }
- }
-
- return;
- }
+ PlaySoundLevel(x, y, SND_SP_BUGGY_BASE_ACTIVE);
- Feld[x][y] = EL_SP_BUGGY_BASE;
- DrawLevelField(x, y);
+ break;
}
}
}
-static void CheckTrap(int x, int y)
+static void InitTrap(int x, int y)
{
- int element = Feld[x][y];
-
- if (element == EL_TRAP)
- {
- if (!MovDelay[x][y]) /* wait some time before activating trap */
- MovDelay[x][y] = 2 * FRAMES_PER_SECOND + RND(5 * FRAMES_PER_SECOND);
-
- if (MovDelay[x][y])
- {
- MovDelay[x][y]--;
- if (MovDelay[x][y])
- return;
-
- 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]) /* start activating trap */
- MovDelay[x][y] = num_frames * delay;
-
- if (MovDelay[x][y])
- {
- MovDelay[x][y]--;
-
- if (MovDelay[x][y])
- {
- if (!(MovDelay[x][y] % delay))
- {
- if (IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
- {
- int graphic = IMG_TRAP_ACTIVE;
- int frame = getGraphicAnimationFrame(graphic, 31 - MovDelay[x][y]);
-
- DrawGraphic(SCREENX(x),SCREENY(y), graphic, frame);
- DrawCrumbledSand(SCREENX(x), SCREENY(y));
- }
- }
-
- return;
- }
-
- Feld[x][y] = EL_TRAP;
- DrawLevelField(x, y);
- }
- }
+ MovDelay[x][y] = 2 * FRAMES_PER_SECOND + RND(5 * FRAMES_PER_SECOND);
}
-static void DrawBeltAnimation(int x, int y, int element)
+static void ActivateTrap(int x, int y)
{
- int belt_nr = getBeltNrFromBeltActiveElement(element);
- int belt_dir = game.belt_dir[belt_nr];
+ PlaySoundLevel(x, y, SND_TRAP_ACTIVATING);
+}
- if (belt_dir != MV_NO_MOVING)
- {
- DrawLevelElementAnimation(x, y, element);
+static void ChangeActiveTrap(int x, int y)
+{
+ int graphic = IMG_TRAP_ACTIVE;
- 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));
}
static void ChangeElement(int x, int y)
{
int element = Feld[x][y];
- int change_delay = changing_element[element].change_delay;
- if (!MovDelay[x][y]) /* next animation frame */
+ if (MovDelay[x][y] == 0) /* initialize element change */
{
- MovDelay[x][y] = change_delay + 1;
- GfxFrame[x][y] = 0;
+ MovDelay[x][y] = changing_element[element].change_delay + 1;
+
+ ResetGfxAnimation(x, y);
+
+ if (changing_element[element].pre_change_function)
+ changing_element[element].pre_change_function(x, y);
}
- if (MovDelay[x][y]) /* wait some time before next frame */
- {
- MovDelay[x][y]--;
+ MovDelay[x][y]--;
- if (MovDelay[x][y])
- {
- DrawLevelElementAnimation(x, y, element);
+ if (MovDelay[x][y] != 0) /* continue element change */
+ {
+ if (IS_ANIMATED(el2img(element)))
+ DrawLevelElementAnimationIfNeeded(x, y, element);
- return;
- }
+ if (changing_element[element].change_function)
+ changing_element[element].change_function(x, y);
}
+ else /* finish element change */
+ {
+ Feld[x][y] = changing_element[element].next_element;
- Feld[x][y] = changing_element[element].next_element;
- DrawLevelField(x, y);
+ ResetGfxAnimation(x, y);
- if (changing_element[element].changer_function)
- changing_element[element].changer_function(x, y);
+ DrawLevelField(x, y);
+
+ if (changing_element[element].post_change_function)
+ changing_element[element].post_change_function(x, y);
+ }
}
static void PlayerActions(struct PlayerInfo *player, byte player_action)
{
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;
element = Feld[x][y];
graphic = el2img(element);
+#if 1
+ if (graphic_info[graphic].anim_global_sync)
+ GfxFrame[x][y] = FrameCounter;
+#endif
+
+ if (ANIM_MODE(graphic) == ANIM_RANDOM &&
+ IS_NEW_FRAME(GfxFrame[x][y], graphic))
+ ResetRandomAnimationValue(x, y);
+
+ SetRandomAnimationValue(x, y);
+
if (IS_INACTIVE(element))
{
#if 1
- if (new_graphic_info[graphic].anim_frames > 1)
- DrawLevelGraphicAnimation(x, y, graphic);
+ if (IS_ANIMATED(graphic))
+ DrawLevelGraphicAnimationIfNeeded(x, y, graphic);
#endif
continue;
{
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);
element == EL_EXTRA_TIME ||
element == EL_SHIELD_NORMAL ||
element == EL_SHIELD_DEADLY) &&
- new_graphic_info[graphic].anim_frames > 1)
- DrawLevelGraphicAnimation(x, y, graphic);
+ IS_ANIMATED(graphic))
+ DrawLevelGraphicAnimationIfNeeded(x, y, graphic);
#endif
else if (IS_MOVING(x, y))
else if (element == EL_GAMEOFLIFE || element == EL_BIOMAZE)
Life(x, y);
+#if 0
else if (element == EL_ROBOT_WHEEL_ACTIVE)
RobotWheel(x, y);
else if (element == EL_TIMEGATE_SWITCH_ACTIVE)
TimegateWheel(x, y);
+#endif
+#if 0
else if (element == EL_ACID_SPLASH_LEFT ||
element == EL_ACID_SPLASH_RIGHT)
- Blurb(x, y);
+ SplashAcid(x, y);
+#endif
#if 0
else if (element == EL_NUT_CRACKING)
NussKnacken(x, y);
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);
+ CheckExitSP(x, y);
+#if 0
else if (element == EL_EXIT_OPENING)
AusgangstuerOeffnen(x, y);
+#endif
else if (element == EL_WALL_GROWING_ACTIVE)
MauerWaechst(x, y);
else if (element == EL_WALL_GROWING ||
MauerAbleger(x, y);
else if (element == EL_FLAMES)
CheckForDragon(x, y);
- else if (element == EL_SP_BUGGY_BASE || element == EL_SP_BUGGY_BASE_ACTIVE)
+#if 0
+ 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)
+ else if (element == EL_TRAP ||
+ element == EL_TRAP_ACTIVE)
CheckTrap(x, y);
-#if 0
else if (IS_BELT_ACTIVE(element))
DrawBeltAnimation(x, y, element);
-#endif
else if (element == EL_SWITCHGATE_OPENING)
OpenSwitchgate(x, y);
else if (element == EL_SWITCHGATE_CLOSING)
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);
+ else if (element == EL_EXPLOSION)
+ ; /* drawing of correct explosion animation is handled separately */
+ else if (IS_ANIMATED(graphic))
+ DrawLevelGraphicAnimationIfNeeded(x, y, graphic);
#endif
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;
}
}
}
{
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)
{
if (element == EL_ACID && dx == 0 && dy == 1)
{
- Blurb(jx, jy);
+ SplashAcid(jx, jy);
Feld[jx][jy] = EL_PLAYER1;
InitMovingField(jx, jy, MV_DOWN);
Store[jx][jy] = EL_ACID;
case EL_TRAP:
case EL_SP_BASE:
case EL_SP_BUGGY_BASE:
+ case EL_SP_BUGGY_BASE_ACTIVATING:
RemoveField(x, y);
- PlaySoundLevelElementAction(x, y, element, SND_ACTION_DIGGING);
+ PlaySoundLevelElementAction(x, y, element, ACTION_DIGGING);
break;
case EL_EMERALD:
DrawText(DX_EMERALDS, DY_EMERALDS,
int2str(local_player->gems_still_needed, 3),
FS_SMALL, FC_YELLOW);
- PlaySoundLevelElementAction(x, y, element, SND_ACTION_COLLECTING);
+ PlaySoundLevelElementAction(x, y, element, ACTION_COLLECTING);
break;
case EL_SPEED_PILL:
DrawText(DX_DYNAMITE, DY_DYNAMITE,
int2str(local_player->dynamite, 3),
FS_SMALL, FC_YELLOW);
- PlaySoundLevelElementAction(x, y, element, SND_ACTION_COLLECTING);
+ PlaySoundLevelElementAction(x, y, element, ACTION_COLLECTING);
break;
case EL_DYNABOMB_NR:
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:
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:
{
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);
if (element != EL_EMPTY)
Store[jx][jy] = element;
+ MovDelay[jx][jy] = 96;
+
+ ResetGfxAnimation(jx, jy);
+
if (player->dynamite)
{
Feld[jx][jy] = EL_DYNAMITE_ACTIVE;
- MovDelay[jx][jy] = 96;
player->dynamite--;
+
DrawText(DX_DYNAMITE, DY_DYNAMITE, int2str(local_player->dynamite, 3),
FS_SMALL, FC_YELLOW);
if (IN_SCR_FIELD(SCREENX(jx), SCREENY(jy)))
{
Feld[jx][jy] =
EL_DYNABOMB_PLAYER1_ACTIVE + (player->element_nr - EL_PLAYER1);
- MovDelay[jx][jy] = 96;
player->dynabombs_left--;
+
if (IN_SCR_FIELD(SCREENX(jx), SCREENY(jy)))
DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), el2img(Feld[jx][jy]), 0);
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;
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)
+{
+ 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 sound_action)
{
PlaySoundLevelElementAction(x, y, Feld[x][y], sound_action);
}
-void PlaySoundLevelElementAction(int x, int y, int element, int sound_action)
+static void PlaySoundLevelElementAction(int x, int y, int element,
+ int sound_action)
{
- int sound_effect = element_action_sound[element][sound_action];
+ int sound_effect = element_info[element].sound[sound_action];
- if (sound_effect != -1)
+ if (sound_effect != SND_UNDEFINED)
PlaySoundLevel(x, y, sound_effect);
}
for (i=0; i<NUM_GAME_BUTTONS; i++)
{
- Bitmap *gd_bitmap = new_graphic_info[IMG_GLOBAL_DOOR].bitmap;
+ Bitmap *gd_bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap;
struct GadgetInfo *gi;
int button_type;
boolean checked;