#include "joystick.h"
#include "network.h"
+/* this switch controls how rocks move horizontally */
+#define OLD_GAME_BEHAVIOUR FALSE
+
/* for DigField() */
#define DF_NO_PUSH 0
#define DF_DIG 1
checksum += mult++ * StorePlayer[x][y];
checksum += mult++ * Frame[x][y];
checksum += mult++ * AmoebaNr[x][y];
- checksum += mult++ * JustHit[x][y];
+ checksum += mult++ * JustStopped[x][y];
checksum += mult++ * Stop[x][y];
*/
}
InitJoysticks();
}
+static int getBeltNrFromElement(int element)
+{
+ return (element < EL_BELT2_LEFT ? 0 :
+ element < EL_BELT3_LEFT ? 1 :
+ element < EL_BELT4_LEFT ? 2 : 3);
+}
+
+static int getBeltNrFromSwitchElement(int element)
+{
+ return (element < EL_BELT2_SWITCH_L ? 0 :
+ element < EL_BELT3_SWITCH_L ? 1 :
+ element < EL_BELT4_SWITCH_L ? 2 : 3);
+}
+
+static int getBeltDirNrFromSwitchElement(int element)
+{
+ static int belt_base_element[4] =
+ {
+ EL_BELT1_SWITCH_L,
+ EL_BELT2_SWITCH_L,
+ EL_BELT3_SWITCH_L,
+ EL_BELT4_SWITCH_L
+ };
+
+ int belt_nr = getBeltNrFromSwitchElement(element);
+ int belt_dir_nr = element - belt_base_element[belt_nr];
+
+ return (belt_dir_nr % 3);
+}
+
+static int getBeltDirFromSwitchElement(int element)
+{
+ static int belt_move_dir[3] =
+ {
+ MV_LEFT,
+ MV_NO_MOVING,
+ MV_RIGHT
+ };
+
+ int belt_dir_nr = getBeltDirNrFromSwitchElement(element);
+
+ return belt_move_dir[belt_dir_nr];
+}
+
static void InitField(int x, int y, boolean init_game)
{
switch (Feld[x][y])
if (!options.network || player->connected)
{
player->active = TRUE;
- player->gone = FALSE;
/* remove potentially duplicate players */
if (StorePlayer[jx][jy] == Feld[x][y])
}
break;
- case EL_DYNAMIT:
+ case EL_DYNAMITE_ACTIVE:
MovDelay[x][y] = 96;
break;
Feld[x][y] = EL_EM_KEY_4;
break;
+ case EL_BELT1_SWITCH_L:
+ case EL_BELT1_SWITCH_M:
+ case EL_BELT1_SWITCH_R:
+ case EL_BELT2_SWITCH_L:
+ case EL_BELT2_SWITCH_M:
+ case EL_BELT2_SWITCH_R:
+ case EL_BELT3_SWITCH_L:
+ case EL_BELT3_SWITCH_M:
+ case EL_BELT3_SWITCH_R:
+ case EL_BELT4_SWITCH_L:
+ case EL_BELT4_SWITCH_M:
+ case EL_BELT4_SWITCH_R:
+ if (init_game)
+ {
+ int belt_nr = getBeltNrFromSwitchElement(Feld[x][y]);
+ int belt_dir = getBeltDirFromSwitchElement(Feld[x][y]);
+ int belt_dir_nr = getBeltDirNrFromSwitchElement(Feld[x][y]);
+
+ if (game.belt_dir_nr[belt_nr] == 3) /* initial value */
+ {
+ game.belt_dir[belt_nr] = belt_dir;
+ game.belt_dir_nr[belt_nr] = belt_dir_nr;
+ }
+ else /* more than one switch -- set it like the first switch */
+ {
+ Feld[x][y] = Feld[x][y] - belt_dir_nr + game.belt_dir_nr[belt_nr];
+ }
+ }
+ break;
+
+ case EL_SWITCHGATE_SWITCH_2: /* always start with same switch pos */
+ if (init_game)
+ Feld[x][y] = EL_SWITCHGATE_SWITCH_1;
+ break;
+
+ case EL_LIGHT_SWITCH_ON:
+ if (init_game)
+ game.light_time_left = 10 * FRAMES_PER_SECOND;
+ break;
+
default:
break;
}
player->programmed_action = 0;
player->score = 0;
- player->gems_still_needed = level.edelsteine;
+ player->gems_still_needed = level.gems_needed;
player->sokobanfields_still_needed = 0;
player->lights_still_needed = 0;
player->friends_still_needed = 0;
player->dynamite = 0;
player->dynabomb_count = 0;
- player->dynabomb_size = 0;
+ player->dynabomb_size = 1;
player->dynabombs_left = 0;
player->dynabomb_xl = FALSE;
player->MovDir = MV_NO_MOVING;
player->MovPos = 0;
player->Pushing = FALSE;
+ player->Switching = FALSE;
player->GfxPos = 0;
player->Frame = 0;
player->snapped = FALSE;
- player->gone = TRUE;
-
player->last_jx = player->last_jy = 0;
player->jx = player->jy = 0;
ZX = ZY = -1;
- MampferNr = 0;
+ game.yam_content_nr = 0;
FrameCounter = 0;
TimeFrames = 0;
TimePlayed = 0;
ScrollStepSize = 0; /* will be correctly initialized by ScrollScreen() */
AllPlayersGone = FALSE;
- SiebAktiv = FALSE;
- SiebCount = 0;
+ game.magic_wall_active = FALSE;
+ game.magic_wall_time_left = 0;
+ game.switchgate_pos = 0;
+ game.light_time_left = 0;
+ for (i=0; i<4; i++)
+ {
+ game.belt_dir[i] = MV_NO_MOVING;
+ game.belt_dir_nr[i] = 3; /* not moving, next moving left */
+ }
for (i=0; i<MAX_NUM_AMOEBA; i++)
AmoebaCnt[i] = AmoebaCnt2[i] = 0;
Store[x][y] = Store2[x][y] = StorePlayer[x][y] = 0;
Frame[x][y] = 0;
AmoebaNr[x][y] = 0;
- JustHit[x][y] = 0;
+ JustStopped[x][y] = 0;
Stop[x][y] = FALSE;
}
}
}
}
+ /* correct non-moving belts to start moving left */
+ for (i=0; i<4; i++)
+ if (game.belt_dir[i] == MV_NO_MOVING)
+ game.belt_dir_nr[i] = 3; /* not moving, next moving left */
+
/* check if any connected player was not found in playfield */
for (i=0; i<MAX_PLAYERS; i++)
{
{
player->present = TRUE;
player->active = TRUE;
- player->gone = FALSE;
some_player->present = FALSE;
StorePlayer[jx][jy] = player->element_nr;
int jx = player->jx, jy = player->jy;
player->active = FALSE;
- player->gone = TRUE;
StorePlayer[jx][jy] = 0;
Feld[jx][jy] = EL_LEERRAUM;
}
int jx = player->jx, jy = player->jy;
player->active = FALSE;
- player->gone = TRUE;
StorePlayer[jx][jy] = 0;
Feld[jx][jy] = EL_LEERRAUM;
}
}
}
- game_emulation = (emulate_bd ? EMU_BOULDERDASH :
+ game.emulation = (emulate_bd ? EMU_BOULDERDASH :
emulate_sb ? EMU_SOKOBAN :
emulate_sp ? EMU_SUPAPLEX : EMU_NONE);
- /* determine border element for this level */
- SetBorderElement();
-
if (BorderElement == EL_LEERRAUM)
{
SBX_Left = 0;
DrawAllPlayers();
FadeToFront();
+ if (setup.soft_scrolling)
+ XCopyArea(display, fieldbuffer, backbuffer, gc,
+ FX, FY, SXSIZE, SYSIZE, SX, SY);
+
+ redraw_mask |= REDRAW_FROM_BACKBUFFER;
+
/* copy default game door content to main double buffer */
XCopyArea(display, pix[PIX_DOOR], drawto, gc,
DOOR_GFX_PAGEX5, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
- DrawText(DX + XX_LEVEL, DY + YY_LEVEL,
- int2str(level_nr, 2), FS_SMALL, FC_YELLOW);
+ if (level_nr < 100)
+ DrawText(DX + XX_LEVEL, DY + YY_LEVEL,
+ int2str(level_nr, 2), FS_SMALL, FC_YELLOW);
+ else
+ {
+ DrawTextExt(drawto, gc, DX + XX_EMERALDS, DY + YY_EMERALDS,
+ int2str(level_nr, 3), FS_SMALL, FC_SPECIAL3);
+ XCopyArea(display, drawto, drawto, gc,
+ DX + XX_EMERALDS, DY + YY_EMERALDS + 1,
+ FONT5_XSIZE * 3, FONT5_YSIZE - 1,
+ DX + XX_LEVEL - 1, DY + YY_LEVEL + 1);
+ }
+
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), FS_SMALL, FC_YELLOW);
DrawText(DX + XX_DYNAMITE, DY + YY_DYNAMITE,
int2str(local_player->dynamite, 3), FS_SMALL, FC_YELLOW);
DrawText(DX + XX_SCORE, DY + YY_SCORE,
#ifdef ONE_PER_NAME
put_into_list:
#endif
- strncpy(highscore[k].Name, setup.player_name, MAX_NAMELEN - 1);
- highscore[k].Name[MAX_NAMELEN - 1] = '\0';
+ strncpy(highscore[k].Name, setup.player_name, MAX_PLAYER_NAME_LEN);
+ highscore[k].Name[MAX_PLAYER_NAME_LEN] = '\0';
highscore[k].Score = local_player->score;
position = k;
break;
}
#ifdef ONE_PER_NAME
- else if (!strncmp(setup.player_name, highscore[k].Name, MAX_NAMELEN - 1))
+ else if (!strncmp(setup.player_name, highscore[k].Name,
+ MAX_PLAYER_NAME_LEN))
break; /* player already there with a higher score */
#endif
if (Store[x][y])
DrawGraphic(sx, sy, el2gfx(Store[x][y]));
- if (Feld[x][y] == EL_DYNAMIT)
+ if (Feld[x][y] == EL_DYNAMITE_ACTIVE)
{
if ((phase = (96 - MovDelay[x][y]) / 12) > 6)
phase = 6;
phase = 7 - phase;
}
- if (game_emulation == EMU_SUPAPLEX)
+ if (game.emulation == EMU_SUPAPLEX)
DrawGraphic(sx, sy, GFX_SP_DISK_RED);
else if (Store[x][y])
DrawGraphicThruMask(sx, sy, graphic + phase);
if (!(MovDelay[x][y] % 12))
PlaySoundLevel(x, y, SND_ZISCH);
- if (Feld[x][y] == EL_DYNAMIT && !(MovDelay[x][y] % 12))
- DrawDynamite(x, y);
- else if (Feld[x][y] == EL_DYNABOMB && !(MovDelay[x][y] % 6))
- DrawDynamite(x, y);
+ 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);
+ }
return;
}
if (IS_MOVING(ex, ey) || IS_BLOCKED(ex, ey))
{
+ /* put moving element to center field (and let it explode there) */
center_element = MovingOrBlocked2Element(ex, ey);
RemoveMovingField(ex, ey);
+ Feld[ex][ey] = center_element;
}
- for (y=ey-1; y<ey+2; y++) for(x=ex-1; x<ex+2; x++)
+ for (y=ey-1; y<=ey+1; y++) for(x=ex-1; x<=ex+1; x++)
{
- int element = Feld[x][y];
+ int element;
+
+ if (!IN_LEV_FIELD(x, y) ||
+ ((mode != EX_NORMAL || center_element == EL_AMOEBA2DIAM) &&
+ (x != ex || y != ey)))
+ continue;
+
+ element = Feld[x][y];
if (IS_MOVING(x, y) || IS_BLOCKED(x, y))
{
RemoveMovingField(x, y);
}
- if (!IN_LEV_FIELD(x, y) || IS_MASSIVE(element) || element == EL_BURNING)
- continue;
-
- if ((mode!=EX_NORMAL || center_element == EL_AMOEBA2DIAM) &&
- (x!=ex || y!=ey))
+ if (IS_MASSIVE(element) || element == EL_BURNING)
continue;
if (element == EL_EXPLODING)
break;
}
- if (game_emulation == EMU_SUPAPLEX)
+ if (game.emulation == EMU_SUPAPLEX)
Store[x][y] = EL_LEERRAUM;
}
else if (center_element == EL_MAULWURF)
else if (center_element == EL_SP_ELECTRON)
Store[x][y] = EL_SP_INFOTRON;
else if (center_element == EL_MAMPFER)
- Store[x][y] = level.mampfer_inhalt[MampferNr][x-ex+1][y-ey+1];
+ Store[x][y] = level.yam_content[game.yam_content_nr][x-ex+1][y-ey+1];
else if (center_element == EL_AMOEBA2DIAM)
- Store[x][y] = level.amoebe_inhalt;
+ Store[x][y] = level.amoeba_content;
else if (element == EL_ERZ_EDEL)
Store[x][y] = EL_EDELSTEIN;
else if (element == EL_ERZ_DIAM)
}
if (center_element == EL_MAMPFER)
- MampferNr = (MampferNr + 1) % MampferMax;
+ game.yam_content_nr = (game.yam_content_nr + 1) % level.num_yam_contents;
return;
}
{
int graphic = GFX_EXPLOSION;
- if (game_emulation == EMU_SUPAPLEX)
+ if (game.emulation == EMU_SUPAPLEX)
graphic = (Store[x][y] == EL_SP_INFOTRON ?
GFX_SP_EXPLODE_INFOTRON :
GFX_SP_EXPLODE_EMPTY);
void DynaExplode(int ex, int ey)
{
int i, j;
- struct PlayerInfo *player = &stored_player[Store2[ex][ey] - EL_SPIELER1];
+ int dynabomb_size = 1;
+ boolean dynabomb_xl = FALSE;
+ struct PlayerInfo *player;
static int xy[4][2] =
{
{ 0, -1 },
{ 0, +1 }
};
- Store2[ex][ey] = 0; /* delete player information */
+ if (IS_ACTIVE_BOMB(Feld[ex][ey]))
+ {
+ player = &stored_player[Feld[ex][ey] - EL_DYNABOMB_ACTIVE_1];
+ dynabomb_size = player->dynabomb_size;
+ dynabomb_xl = player->dynabomb_xl;
+ player->dynabombs_left++;
+ }
Explode(ex, ey, EX_PHASE_START, EX_CENTER);
for (i=0; i<4; i++)
{
- for (j=1; j<=player->dynabomb_size; j++)
+ for (j=1; j<=dynabomb_size; j++)
{
- int x = ex+j*xy[i%4][0];
- int y = ey+j*xy[i%4][1];
+ int x = ex + j * xy[i % 4][0];
+ int y = ey + j * xy[i % 4][1];
int element;
if (!IN_LEV_FIELD(x, y) || IS_MASSIVE(Feld[x][y]))
break;
element = Feld[x][y];
+
+ /* do not restart explosions of fields with active bombs */
+ if (element == EL_EXPLODING && IS_ACTIVE_BOMB(Store2[x][y]))
+ continue;
+
Explode(x, y, EX_PHASE_START, EX_BORDER);
if (element != EL_LEERRAUM &&
element != EL_ERDREICH &&
element != EL_EXPLODING &&
- !player->dynabomb_xl)
+ !dynabomb_xl)
break;
}
}
-
- player->dynabombs_left++;
}
void Bang(int x, int y)
{
int element = Feld[x][y];
- if (game_emulation == EMU_SUPAPLEX)
+ if (game.emulation == EMU_SUPAPLEX)
PlaySoundLevel(x, y, SND_SP_BOOOM);
else
PlaySoundLevel(x, y, SND_ROAAAR);
RaiseScoreElement(element);
Explode(x, y, EX_PHASE_START, EX_NORMAL);
break;
- case EL_DYNABOMB:
+ case EL_DYNABOMB_ACTIVE_1:
+ case EL_DYNABOMB_ACTIVE_2:
+ case EL_DYNABOMB_ACTIVE_3:
+ case EL_DYNABOMB_ACTIVE_4:
case EL_DYNABOMB_NR:
case EL_DYNABOMB_SZ:
case EL_DYNABOMB_XL:
if (Feld[x][y] == smashed)
Feld[x][y] = activated_magic_wall;
- SiebCount = level.dauer_sieb * FRAMES_PER_SECOND;
- SiebAktiv = TRUE;
+ game.magic_wall_time_left = level.time_magic_wall * FRAMES_PER_SECOND;
+ game.magic_wall_active = TRUE;
}
if (IS_PLAYER(x, y+1))
struct PlayerInfo *player = &stored_player[i];
int jx = player->jx, jy = player->jy;
- if (!player->active || player->gone)
+ if (!player->active)
continue;
if (attr_x == -1 || ABS(jx-x)+ABS(jy-y) < ABS(attr_x-x)+ABS(attr_y-y))
{
struct PlayerInfo *player = &stored_player[i];
- if (player->active && !player->gone &&
- player->Pushing && player->MovPos)
+ if (player->active && player->Pushing && player->MovPos)
{
int next_jx = player->jx + (player->jx - player->last_jx);
int next_jy = player->jy + (player->jy - player->last_jy);
InitMovingField(x, y, MV_DOWN);
Store[x][y] = EL_SALZSAEURE;
}
- else if (CAN_SMASH(element) && Feld[x][y+1] == EL_BLOCKED && JustHit[x][y])
+ else if (CAN_SMASH(element) && Feld[x][y+1] == EL_BLOCKED &&
+ JustStopped[x][y])
{
Impact(x, y);
}
Feld[x][y] = EL_AMOEBING;
Store[x][y] = EL_AMOEBE_NASS;
}
+#if OLD_GAME_BEHAVIOUR
else if (IS_SLIPPERY(Feld[x][y+1]) && !Store[x][y+1])
+#else
+ else if (IS_SLIPPERY(Feld[x][y+1]) && !Store[x][y+1] &&
+ !IS_FALLING(x, y+1) && !JustStopped[x][y+1])
+#endif
{
boolean left = (x>0 && IS_FREE(x-1, y) &&
(IS_FREE(x-1, y+1) || Feld[x-1][y+1] == EL_SALZSAEURE));
if (left || right)
{
- if (left && right && game_emulation != EMU_BOULDERDASH)
+ if (left && right && game.emulation != EMU_BOULDERDASH)
left = !(right = RND(2));
InitMovingField(x, y, left ? MV_LEFT : MV_RIGHT);
}
}
+ else if (IS_BELT(Feld[x][y+1]))
+ {
+ boolean left_is_free = (x>0 && IS_FREE(x-1, y));
+ boolean right_is_free = (x<lev_fieldx-1 && IS_FREE(x+1, y));
+ int belt_nr = getBeltNrFromElement(Feld[x][y+1]);
+ int belt_dir = game.belt_dir[belt_nr];
+
+ if ((belt_dir == MV_LEFT && left_is_free) ||
+ (belt_dir == MV_RIGHT && right_is_free))
+ InitMovingField(x, y, belt_dir);
+ }
}
else if (CAN_MOVE(element))
{
int dy = (direction == MV_UP ? -1 : direction == MV_DOWN ? +1 : 0);
int horiz_move = (dx!=0);
int newx = x + dx, newy = y + dy;
- int step = (horiz_move ? dx : dy) * TILEX/8;
+ int step = (horiz_move ? dx : dy) * TILEX / 8;
- if (CAN_FALL(element) && horiz_move && !IS_SP_ELEMENT(element))
- step*=2;
- else if (element == EL_TROPFEN)
- step/=2;
+ if (element == EL_TROPFEN)
+ step /= 2;
else if (Store[x][y] == EL_MORAST_VOLL || Store[x][y] == EL_MORAST_LEER)
- step/=4;
+ step /= 4;
+ else if (CAN_FALL(element) && horiz_move &&
+ y < lev_fieldy-1 && IS_BELT(Feld[x][y+1]))
+ step /= 2;
+
+#if OLD_GAME_BEHAVIOUR
+ else if (CAN_FALL(element) && horiz_move && !IS_SP_ELEMENT(element))
+ step*=2;
+#endif
MovPos[x][y] += step;
else if (Store[x][y] == EL_SIEB_VOLL)
{
Store[x][y] = 0;
- element = Feld[newx][newy] = (SiebAktiv ? EL_SIEB_VOLL : EL_SIEB_TOT);
+ element = Feld[newx][newy] =
+ (game.magic_wall_active ? EL_SIEB_VOLL : EL_SIEB_TOT);
}
else if (Store[x][y] == EL_SIEB_LEER)
{
Store[x][y] = Store2[x][y] = 0;
- Feld[x][y] = (SiebAktiv ? EL_SIEB_LEER : EL_SIEB_TOT);
+ Feld[x][y] = (game.magic_wall_active ? EL_SIEB_LEER : EL_SIEB_TOT);
}
else if (Store[x][y] == EL_SIEB2_VOLL)
{
Store[x][y] = 0;
- element = Feld[newx][newy] = (SiebAktiv ? EL_SIEB2_VOLL : EL_SIEB2_TOT);
+ element = Feld[newx][newy] =
+ (game.magic_wall_active ? EL_SIEB2_VOLL : EL_SIEB2_TOT);
}
else if (Store[x][y] == EL_SIEB2_LEER)
{
Store[x][y] = Store2[x][y] = 0;
- Feld[x][y] = (SiebAktiv ? EL_SIEB2_LEER : EL_SIEB2_TOT);
+ Feld[x][y] = (game.magic_wall_active ? EL_SIEB2_LEER : EL_SIEB2_TOT);
}
else if (Store[x][y] == EL_SALZSAEURE)
{
DrawLevelField(newx, newy);
Stop[newx][newy] = TRUE;
- JustHit[x][newy] = 3;
+ JustStopped[newx][newy] = 3;
if (DONT_TOUCH(element)) /* object may be nasty to player or others */
{
{ 0, +1 }
};
- if (!level.tempo_amoebe)
+ if (!level.amoeba_speed)
{
Feld[ax][ay] = EL_AMOEBE_TOT;
DrawLevelField(ax, ay);
}
if (!MovDelay[ax][ay]) /* start making new amoeba field */
- MovDelay[ax][ay] = RND(FRAMES_PER_SECOND * 25 / (1 + level.tempo_amoebe));
+ MovDelay[ax][ay] = RND(FRAMES_PER_SECOND * 25 / (1 + level.amoeba_speed));
if (MovDelay[ax][ay]) /* wait some time before making new amoeba */
{
if (newax == ax && neway == ay) /* amoeba cannot grow */
{
- if (i == 4 && (!waiting_for_player || game_emulation == EMU_BOULDERDASH))
+ if (i == 4 && (!waiting_for_player || game.emulation == EMU_BOULDERDASH))
{
Feld[ax][ay] = EL_AMOEBE_TOT;
DrawLevelField(ax, ay);
if (element == EL_AMOEBE_VOLL)
AmoebeUmwandeln(ax, ay);
else if (element == EL_AMOEBE_BD)
- AmoebeUmwandelnBD(ax, ay, level.amoebe_inhalt);
+ AmoebeUmwandelnBD(ax, ay, level.amoeba_content);
}
}
return;
void Ablenk(int x, int y)
{
if (!MovDelay[x][y]) /* next animation frame */
- MovDelay[x][y] = level.dauer_ablenk * FRAMES_PER_SECOND;
+ MovDelay[x][y] = level.time_wheel * FRAMES_PER_SECOND;
if (MovDelay[x][y]) /* wait some time before next frame */
{
DrawGraphicAnimation(x, y, GFX_AUSGANG_AUF, 4, 4, ANIM_OSCILLATE);
}
+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 */
+ {
+ int phase;
+
+ MovDelay[x][y]--;
+ phase = MovDelay[x][y] / delay;
+ if (!(MovDelay[x][y] % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
+ DrawGraphic(SCREENX(x), SCREENY(y), GFX_SWITCHGATE_OPEN - phase);
+
+ if (!MovDelay[x][y])
+ {
+ 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 */
+ {
+ int phase;
+
+ MovDelay[x][y]--;
+ phase = MovDelay[x][y] / delay;
+ if (!(MovDelay[x][y] % delay) && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
+ DrawGraphic(SCREENX(x), SCREENY(y), GFX_SWITCHGATE_CLOSED + phase);
+
+ if (!MovDelay[x][y])
+ {
+ Feld[x][y] = EL_SWITCHGATE_CLOSED;
+ DrawLevelField(x, y);
+ }
+ }
+}
+
void EdelsteinFunkeln(int x, int y)
{
if (!IN_SCR_FIELD(SCREENX(x), SCREENY(y)) || IS_MOVING(x, y))
}
}
+static void DrawBeltAnimation(int x, int y, int element)
+{
+ int belt_nr = getBeltNrFromElement(element);
+ int belt_dir = game.belt_dir[belt_nr];
+
+ if (belt_dir != MV_NO_MOVING)
+ {
+ int delay = 2;
+ int mode = (belt_dir == MV_LEFT ? ANIM_NORMAL : ANIM_REVERSE);
+ int graphic = el2gfx(element) + (belt_dir == MV_LEFT ? 0 : 7);
+
+ DrawGraphicAnimation(x, y, graphic, 8, delay, mode);
+ }
+}
+
static void PlayerActions(struct PlayerInfo *player, byte player_action)
{
static byte stored_player_action[MAX_PLAYERS];
stored_player_action[player->index_nr] = 0;
num_stored_actions++;
- if (!player->active || player->gone || tape.pausing)
+ if (!player->active || tape.pausing)
return;
if (player_action)
#ifdef DEBUG
#if 0
- if (TimeFrames == 0 && !local_player->gone)
+ if (TimeFrames == 0 && local_player->active)
{
extern unsigned int last_RND();
for (y=0; y<lev_fieldy; y++) for (x=0; x<lev_fieldx; x++)
{
Stop[x][y] = FALSE;
- if (JustHit[x][y]>0)
- JustHit[x][y]--;
+ if (JustStopped[x][y] > 0)
+ JustStopped[x][y]--;
#if DEBUG
if (IS_BLOCKED(x, y))
}
else if (IS_MOVING(x, y))
ContinueMoving(x, y);
- else if (element == EL_DYNAMIT || element == EL_DYNABOMB)
+ else if (IS_ACTIVE_BOMB(element))
CheckDynamite(x, y);
else if (element == EL_EXPLODING)
Explode(x, y, Frame[x][y], EX_NORMAL);
DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL, 7, 12, ANIM_NORMAL);
else if (element == EL_SP_TERMINAL_ACTIVE)
DrawGraphicAnimation(x, y, GFX2_SP_TERMINAL_ACTIVE, 7, 4, ANIM_NORMAL);
-
- if (SiebAktiv)
+ else if (IS_BELT(element))
+ DrawBeltAnimation(x, y, element);
+ else if (element == EL_SWITCHGATE_OPENING)
+ OpenSwitchgate(x, y);
+ else if (element == EL_SWITCHGATE_CLOSING)
+ CloseSwitchgate(x, y);
+
+ if (game.magic_wall_active)
{
boolean sieb = FALSE;
int jx = local_player->jx, jy = local_player->jy;
}
}
- if (SiebAktiv)
+ if (game.magic_wall_active)
{
- if (!(SiebCount % 4))
+ if (!(game.magic_wall_time_left % 4))
PlaySoundLevel(sieb_x, sieb_y, SND_MIEP);
- if (SiebCount > 0)
+ if (game.magic_wall_time_left > 0)
{
- SiebCount--;
- if (!SiebCount)
+ game.magic_wall_time_left--;
+ if (!game.magic_wall_time_left)
{
for (y=0; y<lev_fieldy; y++) for (x=0; x<lev_fieldx; x++)
{
element = Feld[x][y];
+
if (element == EL_SIEB_LEER || element == EL_SIEB_VOLL)
{
Feld[x][y] = EL_SIEB_TOT;
}
}
- SiebAktiv = FALSE;
+ game.magic_wall_active = FALSE;
+ }
+ }
+ }
+
+ if (game.light_time_left > 0)
+ {
+ game.light_time_left--;
+
+ if (game.light_time_left == 0)
+ {
+ for (y=0; y<lev_fieldy; y++) for (x=0; x<lev_fieldx; x++)
+ {
+ element = Feld[x][y];
+
+ if (element == EL_LIGHT_SWITCH_ON)
+ {
+ Feld[x][y] = EL_LIGHT_SWITCH_OFF;
+ DrawLevelField(x, y);
+ }
+ else if (element == EL_INVISIBLE_STEEL ||
+ element == EL_UNSICHTBAR ||
+ element == EL_SAND_INVISIBLE)
+ DrawLevelField(x, y);
}
}
}
{
int jx = stored_player[i].jx, jy = stored_player[i].jy;
- if (!stored_player[i].active || stored_player[i].gone ||
- &stored_player[i] == player)
+ if (!stored_player[i].active || &stored_player[i] == player)
continue;
min_x = MIN(min_x, jx);
{
int jx = stored_player[i].jx, jy = stored_player[i].jy;
- if (!stored_player[i].active || stored_player[i].gone)
+ if (!stored_player[i].active)
continue;
if (!IN_VIS_FIELD(SCREENX(jx), SCREENY(jy)))
int element;
int can_move;
- if (player->gone || (!dx && !dy))
+ if (!player->active || (!dx && !dy))
return MF_NO_ACTION;
player->MovDir = (dx < 0 ? MV_LEFT :
int old_jx = jx, old_jy = jy;
int moved = MF_NO_ACTION;
- if (player->gone || (!dx && !dy))
+ if (!player->active || (!dx && !dy))
return FALSE;
if (!FrameReached(&player->move_delay, player->move_delay_value) &&
TestIfHeroHitsBadThing(jx, jy);
- if (player->gone)
+ if (!player->active)
RemoveHero(player);
return moved;
int last_jx = player->last_jx, last_jy = player->last_jy;
int move_stepsize = TILEX / player->move_delay_value;
- if (!player->active || player->gone || !player->MovPos)
+ if (!player->active || !player->MovPos)
return;
if (mode == SCROLL_INIT)
{
int jx = player->jx, jy = player->jy;
- if (player->gone)
+ if (!player->active)
return;
if (IS_PFORTE(Feld[jx][jy]))
{
int jx = player->jx, jy = player->jy;
- if (player->gone)
+ if (!player->active)
return;
PlaySoundLevel(jx, jy, SND_AUTSCH);
int jx = player->jx, jy = player->jy;
int i, found = FALSE;
- player->gone = TRUE;
+ player->present = FALSE;
+ player->active = FALSE;
+
StorePlayer[jx][jy] = 0;
for (i=0; i<MAX_PLAYERS; i++)
- if (stored_player[i].active && !stored_player[i].gone)
+ if (stored_player[i].active)
found = TRUE;
if (!found)
if (mode == DF_NO_PUSH)
{
+ player->Switching = FALSE;
player->push_delay = 0;
return MF_NO_ACTION;
}
element = Feld[x][y];
- switch(element)
+ switch (element)
{
case EL_LEERRAUM:
PlaySoundLevel(x, y, SND_EMPTY);
break;
case EL_ERDREICH:
+ case EL_SAND_INVISIBLE:
Feld[x][y] = EL_LEERRAUM;
PlaySoundLevel(x, y, SND_SCHLURF);
break;
PlaySoundLevel(x, y, SND_PONG);
break;
- case EL_DYNAMIT_AUS:
+ case EL_ENVELOPE:
+ Feld[x][y] = EL_LEERRAUM;
+ PlaySoundLevel(x, y, SND_PONG);
+ break;
+
+ case EL_DYNAMITE_INACTIVE:
case EL_SP_DISK_RED:
RemoveField(x, y);
player->dynamite++;
- RaiseScoreElement(EL_DYNAMIT);
+ RaiseScoreElement(EL_DYNAMITE_INACTIVE);
DrawText(DX_DYNAMITE, DY_DYNAMITE,
int2str(local_player->dynamite, 3),
FS_SMALL, FC_YELLOW);
RemoveField(x, y);
player->dynabomb_count++;
player->dynabombs_left++;
- RaiseScoreElement(EL_DYNAMIT);
+ RaiseScoreElement(EL_DYNAMITE_INACTIVE);
PlaySoundLevel(x, y, SND_PONG);
break;
case EL_DYNABOMB_SZ:
RemoveField(x, y);
player->dynabomb_size++;
- RaiseScoreElement(EL_DYNAMIT);
+ RaiseScoreElement(EL_DYNAMITE_INACTIVE);
PlaySoundLevel(x, y, SND_PONG);
break;
case EL_DYNABOMB_XL:
RemoveField(x, y);
player->dynabomb_xl = TRUE;
- RaiseScoreElement(EL_DYNAMIT);
+ RaiseScoreElement(EL_DYNAMITE_INACTIVE);
PlaySoundLevel(x, y, SND_PONG);
break;
}
break;
+ case EL_BELT1_SWITCH_L:
+ case EL_BELT1_SWITCH_M:
+ case EL_BELT1_SWITCH_R:
+ case EL_BELT2_SWITCH_L:
+ case EL_BELT2_SWITCH_M:
+ case EL_BELT2_SWITCH_R:
+ case EL_BELT3_SWITCH_L:
+ case EL_BELT3_SWITCH_M:
+ case EL_BELT3_SWITCH_R:
+ case EL_BELT4_SWITCH_L:
+ case EL_BELT4_SWITCH_M:
+ case EL_BELT4_SWITCH_R:
+ {
+ static int belt_base_element[4] =
+ {
+ EL_BELT1_SWITCH_L,
+ EL_BELT2_SWITCH_L,
+ EL_BELT3_SWITCH_L,
+ EL_BELT4_SWITCH_L
+ };
+ static int belt_move_dir[4] =
+ {
+ MV_LEFT,
+ MV_NO_MOVING,
+ MV_RIGHT,
+ MV_NO_MOVING,
+ };
+
+ int belt_nr = getBeltNrFromSwitchElement(element);
+ int belt_dir_nr = (game.belt_dir_nr[belt_nr] + 1) % 4;
+ int belt_dir = belt_move_dir[belt_dir_nr];
+ int xx, yy;
+
+ if (player->Switching)
+ return MF_ACTION;
+
+ player->Switching = TRUE;
+
+ game.belt_dir_nr[belt_nr] = belt_dir_nr;
+ game.belt_dir[belt_nr] = belt_dir;
+
+ if (belt_dir_nr == 3)
+ belt_dir_nr = 1;
+
+ for (yy=0; yy<lev_fieldy; yy++)
+ {
+ for (xx=0; xx<lev_fieldx; xx++)
+ {
+ int element = Feld[xx][yy];
+
+ if (IS_BELT_SWITCH(element))
+ {
+ int e_belt_nr = getBeltNrFromSwitchElement(element);
+
+ if (e_belt_nr == belt_nr)
+ {
+ Feld[xx][yy] = belt_base_element[belt_nr] + belt_dir_nr;
+ DrawLevelField(xx, yy);
+ }
+ }
+ else if (belt_dir == MV_NO_MOVING && IS_BELT(element))
+ {
+ int e_belt_nr = getBeltNrFromElement(element);
+
+ if (e_belt_nr == belt_nr)
+ DrawLevelField(xx, yy); /* set belt to parking position */
+ }
+ }
+ }
+
+ return MF_ACTION;
+ }
+ break;
+
+ case EL_SWITCHGATE_SWITCH_1:
+ case EL_SWITCHGATE_SWITCH_2:
+ {
+ int xx, yy;
+
+ if (player->Switching)
+ return MF_ACTION;
+
+ player->Switching = TRUE;
+
+ game.switchgate_pos = !game.switchgate_pos;
+
+ for (yy=0; yy<lev_fieldy; yy++)
+ {
+ for (xx=0; xx<lev_fieldx; xx++)
+ {
+ int element = Feld[xx][yy];
+
+ if (element == EL_SWITCHGATE_SWITCH_1 ||
+ element == EL_SWITCHGATE_SWITCH_2)
+ {
+ Feld[xx][yy] = EL_SWITCHGATE_SWITCH_1 + game.switchgate_pos;
+ DrawLevelField(xx, yy);
+ }
+ else if (element == EL_SWITCHGATE_OPEN ||
+ element == EL_SWITCHGATE_OPENING)
+ {
+ Feld[xx][yy] = EL_SWITCHGATE_CLOSING;
+ PlaySoundLevel(xx, yy, SND_OEFFNEN);
+ }
+ else if (element == EL_SWITCHGATE_CLOSED ||
+ element == EL_SWITCHGATE_CLOSING)
+ {
+ Feld[xx][yy] = EL_SWITCHGATE_OPENING;
+ PlaySoundLevel(xx, yy, SND_OEFFNEN);
+ }
+ }
+ }
+
+ return MF_ACTION;
+ }
+ break;
+
+ case EL_LIGHT_SWITCH_OFF:
+ case EL_LIGHT_SWITCH_ON:
+ {
+ int xx, yy;
+
+ if (player->Switching)
+ return MF_ACTION;
+
+ player->Switching = TRUE;
+
+ game.light_time_left =
+ (element == EL_LIGHT_SWITCH_OFF ? 10 * FRAMES_PER_SECOND : 0);
+
+ for (yy=0; yy<lev_fieldy; yy++)
+ {
+ for (xx=0; xx<lev_fieldx; xx++)
+ {
+ int element = Feld[xx][yy];
+
+ if (element == EL_LIGHT_SWITCH_OFF &&
+ game.light_time_left > 0)
+ {
+ Feld[xx][yy] = EL_LIGHT_SWITCH_ON;
+ DrawLevelField(xx, yy);
+ }
+ else if (element == EL_LIGHT_SWITCH_ON &&
+ game.light_time_left == 0)
+ {
+ Feld[xx][yy] = EL_LIGHT_SWITCH_OFF;
+ DrawLevelField(xx, yy);
+ }
+
+ if (element == EL_INVISIBLE_STEEL ||
+ element == EL_UNSICHTBAR ||
+ element == EL_SAND_INVISIBLE)
+ DrawLevelField(xx, yy);
+ }
+ }
+
+ return MF_ACTION;
+ }
+ break;
+
case EL_SP_EXIT:
if (local_player->gems_still_needed > 0)
return MF_NO_ACTION;
player->programmed_action = move_direction;
DOUBLE_PLAYER_SPEED(player);
+ PlaySoundLevel(x, y, SND_GATE);
+
break;
case EL_EM_GATE_1X:
player->programmed_action = move_direction;
DOUBLE_PLAYER_SPEED(player);
+ PlaySoundLevel(x, y, SND_GATE);
+
+ break;
+
+ case EL_SWITCHGATE_OPEN:
+ if (!IN_LEV_FIELD(x + dx, y + dy) || !IS_FREE(x + dx, y + dy))
+ return MF_NO_ACTION;
+
+ /* automatically move to the next field with double speed */
+ player->programmed_action = move_direction;
+ DOUBLE_PLAYER_SPEED(player);
+
+ PlaySoundLevel(x, y, SND_GATE);
+
break;
case EL_SP_PORT1_LEFT:
player->programmed_action = move_direction;
DOUBLE_PLAYER_SPEED(player);
+ PlaySoundLevel(x, y, SND_GATE);
+
break;
case EL_AUSGANG_ZU:
if (IS_SB_ELEMENT(element) &&
local_player->sokobanfields_still_needed == 0 &&
- game_emulation == EMU_SOKOBAN)
+ game.emulation == EMU_SOKOBAN)
{
player->LevelSolved = player->GameOver = TRUE;
PlaySoundLevel(x, y, SND_BUING);
int jx = player->jx, jy = player->jy;
int x = jx + dx, y = jy + dy;
- if (player->gone || !IN_LEV_FIELD(x, y))
+ if (!player->active || !IN_LEV_FIELD(x, y))
return FALSE;
if (dx && dy)
int jx = player->jx, jy = player->jy;
int element;
- if (player->gone || player->MovPos)
+ if (!player->active || player->MovPos)
return FALSE;
element = Feld[jx][jy];
if ((player->dynamite == 0 && player->dynabombs_left == 0) ||
- element == EL_DYNAMIT || element == EL_DYNABOMB ||
- element == EL_EXPLODING)
+ IS_ACTIVE_BOMB(element) || element == EL_EXPLODING)
return FALSE;
if (element != EL_LEERRAUM)
if (player->dynamite)
{
- Feld[jx][jy] = EL_DYNAMIT;
+ 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)))
{
- if (game_emulation == EMU_SUPAPLEX)
+ if (game.emulation == EMU_SUPAPLEX)
DrawGraphic(SCREENX(jx), SCREENY(jy), GFX_SP_DISK_RED);
else
DrawGraphicThruMask(SCREENX(jx), SCREENY(jy), GFX_DYNAMIT);
}
else
{
- Feld[jx][jy] = EL_DYNABOMB;
- Store2[jx][jy] = player->element_nr; /* for DynaExplode() */
+ Feld[jx][jy] = EL_DYNABOMB_ACTIVE_1 + (player->element_nr - EL_SPIELER1);
MovDelay[jx][jy] = 96;
player->dynabombs_left--;
if (IN_SCR_FIELD(SCREENX(jx), SCREENY(jy)))
case EL_KOKOSNUSS:
RaiseScore(level.score[SC_KOKOSNUSS]);
break;
- case EL_DYNAMIT:
+ case EL_DYNAMITE_INACTIVE:
RaiseScore(level.score[SC_DYNAMIT]);
break;
case EL_SCHLUESSEL: