static struct GadgetInfo *game_gadget[NUM_GAME_BUTTONS];
+
+/* ------------------------------------------------------------------------- */
+/* sound definitions */
+/* ------------------------------------------------------------------------- */
+
#define SND_ACTION_UNKNOWN 0
#define SND_ACTION_WAITING 1
#define SND_ACTION_MOVING 2
#define IS_LOOP_SOUND(x) (is_loop_sound[x])
+/* -------------------------------------------------------------------------
+ definition of elements that automatically change to other elements after
+ a specified time, eventually calling a function when changing
+ ------------------------------------------------------------------------- */
+
+struct ChangingElementInfo
+{
+ int base_element;
+ int next_element;
+ int change_delay;
+ void (*changer_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 }
+};
+
+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)
checksum += mult++ * Store[x][y];
checksum += mult++ * Store2[x][y];
checksum += mult++ * StorePlayer[x][y];
- checksum += mult++ * Frame[x][y];
+ checksum += mult++ * ExplodePhase[x][y];
checksum += mult++ * AmoebaNr[x][y];
checksum += mult++ * JustStopped[x][y];
checksum += mult++ * Stop[x][y];
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<ep_em_slippery_wall_num; i++)
{
if (level.em_slippery_gems) /* special EM style gems behaviour */
- Elementeigenschaften2[ep_em_slippery_wall[i]] |=
+ Properties2[ep_em_slippery_wall[i]] |=
EP_BIT_EM_SLIPPERY_WALL;
else
- Elementeigenschaften2[ep_em_slippery_wall[i]] &=
+ Properties2[ep_em_slippery_wall[i]] &=
~EP_BIT_EM_SLIPPERY_WALL;
}
/* "EL_WALL_GROWING_ACTIVE" wasn't slippery for EM gems in version 2.0.1 */
if (level.em_slippery_gems && game.engine_version > VERSION_IDENT(2,0,1))
- Elementeigenschaften2[EL_WALL_GROWING_ACTIVE] |= EP_BIT_EM_SLIPPERY_WALL;
+ Properties2[EL_WALL_GROWING_ACTIVE] |= EP_BIT_EM_SLIPPERY_WALL;
else
- Elementeigenschaften2[EL_WALL_GROWING_ACTIVE] &=~EP_BIT_EM_SLIPPERY_WALL;
+ Properties2[EL_WALL_GROWING_ACTIVE] &=~EP_BIT_EM_SLIPPERY_WALL;
+ }
+
+ /* initialize changing elements information */
+ for (i=0; i<MAX_NUM_ELEMENTS; i++)
+ {
+ 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;
+ }
+
+ i = 0;
+ while (changing_element_list[i].base_element != EL_UNDEFINED)
+ {
+ 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;
+
+ i++;
}
}
Feld[x][y] = Ur[x][y];
MovPos[x][y] = MovDir[x][y] = MovDelay[x][y] = 0;
Store[x][y] = Store2[x][y] = StorePlayer[x][y] = 0;
- Frame[x][y] = 0;
- GfxAction[x][y] = GFX_ACTION_DEFAULT;
AmoebaNr[x][y] = 0;
JustStopped[x][y] = 0;
Stop[x][y] = FALSE;
+ ExplodePhase[x][y] = 0;
ExplodeField[x][y] = EX_NO_EXPLOSION;
+
+ GfxFrame[x][y] = 0;
+ GfxAction[x][y] = GFX_ACTION_DEFAULT;
}
}
FadeToFront();
/* copy default game door content to main double buffer */
- BlitBitmap(new_graphic_info[IMG_MENU_DOOR].bitmap, drawto,
+ BlitBitmap(new_graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
DOOR_GFX_PAGEX5, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
if (level_nr < 100)
int newx = x + (direction == MV_LEFT ? -1 : direction == MV_RIGHT ? +1 : 0);
int newy = y + (direction == MV_UP ? -1 : direction == MV_DOWN ? +1 : 0);
+ if (!JustStopped[x][y] || direction != MovDir[x][y])
+ GfxFrame[x][y] = 0;
+
MovDir[x][y] = direction;
MovDir[newx][newy] = direction;
Feld[x][y] = EL_EXPLOSION;
MovDir[x][y] = MovPos[x][y] = 0;
AmoebaNr[x][y] = 0;
- Frame[x][y] = 1;
+ ExplodePhase[x][y] = 1;
Stop[x][y] = TRUE;
}
x = ex;
y = ey;
- Frame[x][y] = (phase < last_phase ? phase + 1 : 0);
+ ExplodePhase[x][y] = (phase < last_phase ? phase + 1 : 0);
if (phase == first_phase_after_start)
{
}
}
else if (element == EL_SP_ELECTRON)
- DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_SP_ELECTRON);
+ DrawLevelElementAnimation(x, y, element);
else if (element == EL_DRAGON)
{
int i;
element == EL_SP_SNIKSNAK || element == EL_MOLE)
DrawLevelField(x, y);
else if (element == EL_BD_BUTTERFLY || element == EL_BD_FIREFLY)
- DrawGraphicAnimation(SCREENX(x), SCREENY(y), el2img(element));
+ DrawLevelElementAnimation(x, y, element);
else if (element == EL_SATELLITE)
- DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_SATELLITE);
+ DrawLevelElementAnimation(x, y, element);
else if (element == EL_SP_ELECTRON)
- DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_SP_ELECTRON);
+ DrawLevelElementAnimation(x, y, element);
if (DONT_TOUCH(element))
TestIfBadThingTouchesHero(x, y);
{
int graphic = (type == 1 ? IMG_MAGIC_WALL_FULL : IMG_BD_MAGIC_WALL_FULL);
- DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic);
+ DrawLevelGraphicAnimation(x, y, graphic);
}
void AusgangstuerPruefen(int x, int y)
return;
if (Feld[x][y] == EL_BD_DIAMOND)
- DrawGraphicAnimation(SCREENX(x), SCREENY(y), IMG_BD_DIAMOND);
+ DrawLevelElementAnimation(x, y, el2img(Feld[x][y]));
else
{
if (!MovDelay[x][y]) /* next animation frame */
#if 0
DrawGraphic(SCREENX(x), SCREENY(y), el2img(Feld[x][y]), 0);
#else
- DrawGraphicAnimation(SCREENX(x), SCREENY(y), el2img(Feld[x][y]));
+ DrawLevelElementAnimation(x, y, Feld[x][y]);
#endif
if (MovDelay[x][y])
if (belt_dir != MV_NO_MOVING)
{
- int graphic = el2img(element);
-
- DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic);
+ DrawLevelElementAnimation(x, y, element);
if (!(FrameCounter % 2))
- PlaySoundLevel(x, y, SND_CONVEYOR_BELT_ACTIVE);
+ PlaySoundLevelAction(x, y, SND_ACTION_ACTIVE);
}
}
+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 */
+ {
+ MovDelay[x][y] = change_delay + 1;
+ GfxFrame[x][y] = 0;
+ }
+
+ if (MovDelay[x][y]) /* wait some time before next frame */
+ {
+ MovDelay[x][y]--;
+
+ if (MovDelay[x][y])
+ {
+ DrawLevelElementAnimation(x, y, element);
+
+ return;
+ }
+ }
+
+ Feld[x][y] = changing_element[element].next_element;
+ DrawLevelField(x, y);
+
+ if (changing_element[element].changer_function)
+ changing_element[element].changer_function(x, y);
+}
+
static void PlayerActions(struct PlayerInfo *player, byte player_action)
{
static byte stored_player_action[MAX_PLAYERS];
if (JustStopped[x][y] > 0)
JustStopped[x][y]--;
+ GfxFrame[x][y]++;
+
#if DEBUG
if (IS_BLOCKED(x, y))
{
#if 1
if (new_graphic_info[graphic].anim_frames > 1)
- DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic);
+ DrawLevelGraphicAnimation(x, y, graphic);
#endif
continue;
if (Feld[x][y] == EL_EMERALD &&
new_graphic_info[graphic].anim_frames > 1 &&
!IS_MOVING(x, y))
- DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic);
+ DrawLevelGraphicAnimation(x, y, graphic);
#endif
if (IS_GEM(element) || element == EL_SP_INFOTRON)
element == EL_SHIELD_NORMAL ||
element == EL_SHIELD_DEADLY) &&
new_graphic_info[graphic].anim_frames > 1)
- DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic);
+ DrawLevelGraphicAnimation(x, y, graphic);
#endif
else if (IS_MOVING(x, y))
CheckDynamite(x, y);
#if 0
else if (element == EL_EXPLOSION && !game.explosions_delayed)
- Explode(x, y, Frame[x][y], EX_NORMAL);
+ Explode(x, y, ExplodePhase[x][y], EX_NORMAL);
#endif
else if (element == EL_AMOEBA_CREATING)
AmoebeWaechst(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);
else if (element == EL_SP_EXIT_CLOSED)
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);
+#endif
else if (element == EL_SWITCHGATE_OPENING)
OpenSwitchgate(x, y);
else if (element == EL_SWITCHGATE_CLOSING)
else if (element == EL_TIMEGATE_CLOSING)
CloseTimegate(x, y);
+ else if (IS_AUTO_CHANGING(element))
+ ChangeElement(x, y);
+
#if 1
else if (new_graphic_info[graphic].anim_frames > 1)
- DrawGraphicAnimation(SCREENX(x), SCREENY(y), graphic);
+ DrawLevelGraphicAnimation(x, y, graphic);
#endif
+ if (IS_BELT_ACTIVE(element))
+ PlaySoundLevelAction(x, y, SND_ACTION_ACTIVE);
+
if (game.magic_wall_active)
{
boolean sieb = FALSE;
if (ExplodeField[x][y])
Explode(x, y, EX_PHASE_START, ExplodeField[x][y]);
else if (element == EL_EXPLOSION)
- Explode(x, y, Frame[x][y], EX_NORMAL);
+ Explode(x, y, ExplodePhase[x][y], EX_NORMAL);
ExplodeField[x][y] = EX_NO_EXPLOSION;
}
for (i=0; i<NUM_GAME_BUTTONS; i++)
{
- Bitmap *gd_bitmap = new_graphic_info[IMG_MENU_DOOR].bitmap;
+ Bitmap *gd_bitmap = new_graphic_info[IMG_GLOBAL_DOOR].bitmap;
struct GadgetInfo *gi;
int button_type;
boolean checked;