InitJoysticks();
}
+static void InitField(int x, int y, boolean init_game)
+{
+ switch (Feld[x][y])
+ {
+ case EL_SPIELFIGUR:
+ if (init_game)
+ Feld[x][y] = EL_SPIELER1;
+ /* no break! */
+ case EL_SPIELER1:
+ case EL_SPIELER2:
+ case EL_SPIELER3:
+ case EL_SPIELER4:
+ if (init_game)
+ {
+ struct PlayerInfo *player = &stored_player[Feld[x][y] - EL_SPIELER1];
+ int jx = player->jx, jy = player->jy;
+
+ player->present = TRUE;
+
+ /*
+ if (!network_playing || player->connected)
+ */
+
+ if (!options.network || player->connected)
+ {
+ player->active = TRUE;
+
+ /* remove potentially duplicate players */
+ if (StorePlayer[jx][jy] == Feld[x][y])
+ StorePlayer[jx][jy] = 0;
+
+ StorePlayer[x][y] = Feld[x][y];
+
+ if (options.verbose)
+ {
+ printf("Player %d activated.\n", player->element_nr);
+ printf("[Local player is %d and currently %s.]\n",
+ local_player->element_nr,
+ local_player->active ? "active" : "not active");
+ }
+ }
+
+ Feld[x][y] = EL_LEERRAUM;
+ player->jx = player->last_jx = x;
+ player->jy = player->last_jy = y;
+ }
+ break;
+
+ case EL_BADEWANNE:
+ if (x < lev_fieldx-1 && Feld[x+1][y] == EL_SALZSAEURE)
+ Feld[x][y] = EL_BADEWANNE1;
+ else if (x > 0 && Feld[x-1][y] == EL_SALZSAEURE)
+ Feld[x][y] = EL_BADEWANNE2;
+ else if (y > 0 && Feld[x][y-1] == EL_BADEWANNE1)
+ Feld[x][y] = EL_BADEWANNE3;
+ else if (y > 0 && Feld[x][y-1] == EL_SALZSAEURE)
+ Feld[x][y] = EL_BADEWANNE4;
+ else if (y > 0 && Feld[x][y-1] == EL_BADEWANNE2)
+ Feld[x][y] = EL_BADEWANNE5;
+ break;
+
+ case EL_KAEFER_R:
+ case EL_KAEFER_O:
+ case EL_KAEFER_L:
+ case EL_KAEFER_U:
+ case EL_KAEFER:
+ case EL_FLIEGER_R:
+ case EL_FLIEGER_O:
+ case EL_FLIEGER_L:
+ case EL_FLIEGER_U:
+ case EL_FLIEGER:
+ case EL_BUTTERFLY_R:
+ case EL_BUTTERFLY_O:
+ case EL_BUTTERFLY_L:
+ case EL_BUTTERFLY_U:
+ case EL_BUTTERFLY:
+ case EL_FIREFLY_R:
+ case EL_FIREFLY_O:
+ case EL_FIREFLY_L:
+ case EL_FIREFLY_U:
+ case EL_FIREFLY:
+ case EL_PACMAN_R:
+ case EL_PACMAN_O:
+ case EL_PACMAN_L:
+ case EL_PACMAN_U:
+ case EL_MAMPFER:
+ case EL_MAMPFER2:
+ case EL_ROBOT:
+ case EL_PACMAN:
+ InitMovDir(x, y);
+ break;
+
+ case EL_AMOEBE_VOLL:
+ case EL_AMOEBE_BD:
+ InitAmoebaNr(x, y);
+ break;
+
+ case EL_TROPFEN:
+ if (y == lev_fieldy - 1)
+ {
+ Feld[x][y] = EL_AMOEBING;
+ Store[x][y] = EL_AMOEBE_NASS;
+ }
+ break;
+
+ case EL_DYNAMIT:
+ MovDelay[x][y] = 96;
+ break;
+
+ case EL_BIRNE_AUS:
+ local_player->lights_still_needed++;
+ break;
+
+ case EL_SOKOBAN_FELD_LEER:
+ local_player->sokobanfields_still_needed++;
+ break;
+
+ case EL_MAULWURF:
+ case EL_PINGUIN:
+ local_player->friends_still_needed++;
+ break;
+
+ case EL_SCHWEIN:
+ case EL_DRACHE:
+ MovDir[x][y] = 1 << RND(4);
+ break;
+
+ default:
+ break;
+ }
+}
+
void InitGame()
{
int i, j, x, y;
if (emulate_sb && !IS_SB_ELEMENT(Feld[x][y]))
emulate_sb = FALSE;
- switch (Feld[x][y])
- {
- case EL_SPIELFIGUR:
- Feld[x][y] = EL_SPIELER1;
- /* no break! */
- case EL_SPIELER1:
- case EL_SPIELER2:
- case EL_SPIELER3:
- case EL_SPIELER4:
- {
- struct PlayerInfo *player = &stored_player[Feld[x][y] - EL_SPIELER1];
- int jx = player->jx, jy = player->jy;
-
- player->present = TRUE;
-
- /*
- if (!network_playing || player->connected)
- */
-
- if (!options.network || player->connected)
- {
- player->active = TRUE;
-
- /* remove potentially duplicate players */
- if (StorePlayer[jx][jy] == Feld[x][y])
- StorePlayer[jx][jy] = 0;
-
- StorePlayer[x][y] = Feld[x][y];
-
- if (options.verbose)
- {
- printf("Player %d activated.\n", player->element_nr);
- printf("[Local player is %d and currently %s.]\n",
- local_player->element_nr,
- local_player->active ? "active" : "not active");
- }
- }
-
- Feld[x][y] = EL_LEERRAUM;
- player->jx = player->last_jx = x;
- player->jy = player->last_jy = y;
-
- break;
- }
- case EL_BADEWANNE:
- if (x < lev_fieldx-1 && Feld[x+1][y] == EL_SALZSAEURE)
- Feld[x][y] = EL_BADEWANNE1;
- else if (x > 0 && Feld[x-1][y] == EL_SALZSAEURE)
- Feld[x][y] = EL_BADEWANNE2;
- else if (y > 0 && Feld[x][y-1] == EL_BADEWANNE1)
- Feld[x][y] = EL_BADEWANNE3;
- else if (y > 0 && Feld[x][y-1] == EL_SALZSAEURE)
- Feld[x][y] = EL_BADEWANNE4;
- else if (y > 0 && Feld[x][y-1] == EL_BADEWANNE2)
- Feld[x][y] = EL_BADEWANNE5;
- break;
- case EL_KAEFER_R:
- case EL_KAEFER_O:
- case EL_KAEFER_L:
- case EL_KAEFER_U:
- case EL_KAEFER:
- case EL_FLIEGER_R:
- case EL_FLIEGER_O:
- case EL_FLIEGER_L:
- case EL_FLIEGER_U:
- case EL_FLIEGER:
- case EL_BUTTERFLY_R:
- case EL_BUTTERFLY_O:
- case EL_BUTTERFLY_L:
- case EL_BUTTERFLY_U:
- case EL_BUTTERFLY:
- case EL_FIREFLY_R:
- case EL_FIREFLY_O:
- case EL_FIREFLY_L:
- case EL_FIREFLY_U:
- case EL_FIREFLY:
- case EL_PACMAN_R:
- case EL_PACMAN_O:
- case EL_PACMAN_L:
- case EL_PACMAN_U:
- case EL_MAMPFER:
- case EL_MAMPFER2:
- case EL_ROBOT:
- case EL_PACMAN:
- InitMovDir(x, y);
- break;
- case EL_AMOEBE_VOLL:
- case EL_AMOEBE_BD:
- InitAmoebaNr(x, y);
- break;
- case EL_TROPFEN:
- if (y == lev_fieldy - 1)
- {
- Feld[x][y] = EL_AMOEBING;
- Store[x][y] = EL_AMOEBE_NASS;
- }
- break;
- case EL_DYNAMIT:
- MovDelay[x][y] = 96;
- break;
- case EL_BIRNE_AUS:
- local_player->lights_still_needed++;
- break;
- case EL_SOKOBAN_FELD_LEER:
- local_player->sokobanfields_still_needed++;
- break;
- case EL_MAULWURF:
- case EL_PINGUIN:
- local_player->friends_still_needed++;
- break;
- case EL_SCHWEIN:
- case EL_DRACHE:
- MovDir[x][y] = 1 << RND(4);
- break;
- default:
- break;
- }
+ InitField(x, y, TRUE);
}
/* check if any connected player was not found in playfield */
element = Feld[x][y] = Store[x][y];
Store[x][y] = Store2[x][y] = 0;
MovDir[x][y] = MovPos[x][y] = MovDelay[x][y] = 0;
+ InitField(x, y, FALSE);
if (CAN_MOVE(element) || COULD_MOVE(element))
InitMovDir(x, y);
DrawLevelField(x, y);
for (i=0; i<4; i++)
{
- int x = ax+xy[i%4][0];
- int y = ay+xy[i%4][1];
+ int x = ax + xy[i][0];
+ int y = ay + xy[i][1];
if (!IN_LEV_FIELD(x, y))
continue;
- if (Feld[x][y] == element && AmoebaNr[x][y]>0)
+ if (Feld[x][y] == element && AmoebaNr[x][y] > 0)
group_nr = AmoebaNr[x][y];
}
{ 0, +1 }
};
- if (!new_group_nr)
+ if (new_group_nr == 0)
return;
for (i=0; i<4; i++)
{
- x = ax+xy[i%4][0];
- y = ay+xy[i%4][1];
+ x = ax + xy[i][0];
+ y = ay + xy[i][1];
if (!IN_LEV_FIELD(x, y))
continue;
{
int old_group_nr = AmoebaNr[x][y];
+ if (old_group_nr == 0)
+ return;
+
AmoebaCnt[new_group_nr] += AmoebaCnt[old_group_nr];
AmoebaCnt[old_group_nr] = 0;
AmoebaCnt2[new_group_nr] += AmoebaCnt2[old_group_nr];
AmoebaCnt2[old_group_nr] = 0;
- for (yy=0; yy<lev_fieldy; yy++) for (xx=0; xx<lev_fieldx; xx++)
- if (AmoebaNr[xx][yy] == old_group_nr)
- AmoebaNr[xx][yy] = new_group_nr;
+ for (yy=0; yy<lev_fieldy; yy++)
+ {
+ for (xx=0; xx<lev_fieldx; xx++)
+ {
+ if (AmoebaNr[xx][yy] == old_group_nr)
+ AmoebaNr[xx][yy] = new_group_nr;
+ }
+ }
}
}
}
void AmoebeUmwandeln(int ax, int ay)
{
int i, x, y;
- int group_nr = AmoebaNr[ax][ay];
- static int xy[4][2] =
- {
- { 0, -1 },
- { -1, 0 },
- { +1, 0 },
- { 0, +1 }
- };
if (Feld[ax][ay] == EL_AMOEBE_TOT)
{
- for (y=0; y<lev_fieldy; y++) for (x=0; x<lev_fieldx; x++)
+ int group_nr = AmoebaNr[ax][ay];
+
+#ifdef DEBUG
+ if (group_nr == 0)
+ {
+ printf("AmoebeUmwandeln(): ax = %d, ay = %d\n", ax, ay);
+ printf("AmoebeUmwandeln(): This should never happen!\n");
+ return;
+ }
+#endif
+
+ for (y=0; y<lev_fieldy; y++)
{
- if (Feld[x][y] == EL_AMOEBE_TOT && AmoebaNr[x][y] == group_nr)
+ for (x=0; x<lev_fieldx; x++)
{
- AmoebaNr[x][y] = 0;
- Feld[x][y] = EL_AMOEBA2DIAM;
+ if (Feld[x][y] == EL_AMOEBE_TOT && AmoebaNr[x][y] == group_nr)
+ {
+ AmoebaNr[x][y] = 0;
+ Feld[x][y] = EL_AMOEBA2DIAM;
+ }
}
}
Bang(ax, ay);
}
else
{
+ static int xy[4][2] =
+ {
+ { 0, -1 },
+ { -1, 0 },
+ { +1, 0 },
+ { 0, +1 }
+ };
+
for (i=0; i<4; i++)
{
- x = ax+xy[i%4][0];
- y = ay+xy[i%4][1];
+ x = ax + xy[i][0];
+ y = ay + xy[i][1];
if (!IN_LEV_FIELD(x, y))
continue;
}
}
-void AmoebeUmwandeln2(int ax, int ay, int new_element)
+void AmoebeUmwandelnBD(int ax, int ay, int new_element)
{
int x, y;
int group_nr = AmoebaNr[ax][ay];
boolean done = FALSE;
- for (y=0; y<lev_fieldy; y++) for (x=0; x<lev_fieldx; x++)
+#ifdef DEBUG
+ if (group_nr == 0)
{
- if (AmoebaNr[x][y] == group_nr &&
- (Feld[x][y] == EL_AMOEBE_TOT ||
- Feld[x][y] == EL_AMOEBE_BD ||
- Feld[x][y] == EL_AMOEBING))
+ printf("AmoebeUmwandelnBD(): ax = %d, ay = %d\n", ax, ay);
+ printf("AmoebeUmwandelnBD(): This should never happen!\n");
+ return;
+ }
+#endif
+
+ for (y=0; y<lev_fieldy; y++)
+ {
+ for (x=0; x<lev_fieldx; x++)
{
- AmoebaNr[x][y] = 0;
- Feld[x][y] = new_element;
- DrawLevelField(x, y);
- done = TRUE;
+ if (AmoebaNr[x][y] == group_nr &&
+ (Feld[x][y] == EL_AMOEBE_TOT ||
+ Feld[x][y] == EL_AMOEBE_BD ||
+ Feld[x][y] == EL_AMOEBING))
+ {
+ AmoebaNr[x][y] = 0;
+ Feld[x][y] = new_element;
+ InitField(x, y, FALSE);
+ DrawLevelField(x, y);
+ done = TRUE;
+ }
}
}
{
MovDelay[x][y]--;
if (MovDelay[x][y]/2 && IN_SCR_FIELD(SCREENX(x), SCREENY(y)))
- DrawGraphic(SCREENX(x), SCREENY(y), GFX_AMOEBING+3-MovDelay[x][y]/2);
+ DrawGraphic(SCREENX(x), SCREENY(y), GFX_AMOEBING + 3 - MovDelay[x][y]/2);
if (!MovDelay[x][y])
{
}
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.tempo_amoebe));
if (MovDelay[ax][ay]) /* wait some time before making new amoeba */
{
if (element == EL_AMOEBE_NASS) /* object is an acid / amoeba drop */
{
int start = RND(4);
- int x = ax+xy[start][0];
- int y = ay+xy[start][1];
+ int x = ax + xy[start][0];
+ int y = ay + xy[start][1];
if (!IN_LEV_FIELD(x, y))
return;
if (newax == ax && neway == ay)
return;
}
- else /* normal or "filled" amoeba */
+ else /* normal or "filled" (BD style) amoeba */
{
int start = RND(4);
boolean waiting_for_player = FALSE;
for (i=0; i<4; i++)
{
- int j = (start+i)%4;
- int x = ax+xy[j][0];
- int y = ay+xy[j][1];
+ int j = (start + i) % 4;
+ int x = ax + xy[j][0];
+ int y = ay + xy[j][1];
if (!IN_LEV_FIELD(x, y))
continue;
waiting_for_player = TRUE;
}
- if (newax == ax && neway == ay)
+ if (newax == ax && neway == ay) /* amoeba cannot grow */
{
if (i == 4 && !waiting_for_player)
{
DrawLevelField(ax, ay);
AmoebaCnt[AmoebaNr[ax][ay]]--;
- if (AmoebaCnt[AmoebaNr[ax][ay]]<=0) /* amoeba is completely dead */
+ if (AmoebaCnt[AmoebaNr[ax][ay]] <= 0) /* amoeba is completely dead */
{
if (element == EL_AMOEBE_VOLL)
AmoebeUmwandeln(ax, ay);
else if (element == EL_AMOEBE_BD)
- AmoebeUmwandeln2(ax, ay, level.amoebe_inhalt);
+ AmoebeUmwandelnBD(ax, ay, level.amoebe_inhalt);
}
}
return;
}
else if (element == EL_AMOEBE_VOLL || element == EL_AMOEBE_BD)
{
+ /* amoeba gets larger by growing in some direction */
+
int new_group_nr = AmoebaNr[ax][ay];
+#ifdef DEBUG
+ if (new_group_nr == 0)
+ {
+ printf("AmoebeAbleger(): newax = %d, neway = %d\n", newax, neway);
+ printf("AmoebeAbleger(): This should never happen!\n");
+ return;
+ }
+#endif
+
AmoebaNr[newax][neway] = new_group_nr;
AmoebaCnt[new_group_nr]++;
AmoebaCnt2[new_group_nr]++;
+
+ /* if amoeba touches other amoeba(s) after growing, unify them */
AmoebenVereinigen(newax, neway);
- if (AmoebaCnt2[new_group_nr] >= 200 && element == EL_AMOEBE_BD)
+ if (element == EL_AMOEBE_BD && AmoebaCnt2[new_group_nr] >= 200)
{
- AmoebeUmwandeln2(newax, neway, EL_FELSBROCKEN);
+ AmoebeUmwandelnBD(newax, neway, EL_FELSBROCKEN);
return;
}
}
}
- if (element!=EL_AMOEBE_NASS || neway<ay || !IS_FREE(newax, neway) ||
- (neway == lev_fieldy-1 && newax!=ax))
+ if (element != EL_AMOEBE_NASS || neway < ay || !IS_FREE(newax, neway) ||
+ (neway == lev_fieldy - 1 && newax != ax))
{
Feld[newax][neway] = EL_AMOEBING;
Store[newax][neway] = element;
case EL_EDELSTEIN_ROT:
case EL_EDELSTEIN_LILA:
case EL_DIAMANT:
+ case EL_SP_INFOTRON:
RemoveField(x, y);
local_player->gems_still_needed -= (element == EL_DIAMANT ? 3 : 1);
if (local_player->gems_still_needed < 0)
break;
default:
- return MF_NO_ACTION;
+ if (IS_EATABLE(element)) /* other kinds of 'dirt' */
+ Feld[x][y] = EL_LEERRAUM;
+ else
+ return MF_NO_ACTION;
+
break;
}
#define IN_SCR_FIELD(x,y) ((x)>=BX1 && (x)<=BX2 && (y)>=BY1 &&(y)<=BY2)
#define IN_LEV_FIELD(x,y) ((x)>=0 && (x)<lev_fieldx && (y)>=0 &&(y)<lev_fieldy)
-#define EP_BIT_AMOEBALIVE (1<<0)
-#define EP_BIT_AMOEBOID (1<<1)
-#define EP_BIT_SCHLUESSEL (1<<2)
-#define EP_BIT_PFORTE (1<<3)
-#define EP_BIT_SOLID (1<<4)
-#define EP_BIT_MASSIV (1<<5)
-#define EP_BIT_SLIPPERY (1<<6)
-#define EP_BIT_ENEMY (1<<7)
-#define EP_BIT_MAUER (1<<8)
-#define EP_BIT_CAN_FALL (1<<9)
-#define EP_BIT_CAN_SMASH (1<<10)
-#define EP_BIT_CAN_CHANGE (1<<11)
-#define EP_BIT_CAN_MOVE (1<<12)
-#define EP_BIT_COULD_MOVE (1<<13)
-#define EP_BIT_DONT_TOUCH (1<<14)
-#define EP_BIT_DONT_GO_TO (1<<15)
-#define EP_BIT_MAMPF2 (1<<16)
-#define EP_BIT_CHAR (1<<17)
-#define EP_BIT_BD_ELEMENT (1<<18)
-#define EP_BIT_SB_ELEMENT (1<<19)
-#define EP_BIT_GEM (1<<20)
-#define EP_BIT_INACTIVE (1<<21)
-#define EP_BIT_EXPLOSIVE (1<<22)
-#define EP_BIT_MAMPF3 (1<<23)
-#define EP_BIT_PUSHABLE (1<<24)
-#define EP_BIT_PLAYER (1<<25)
-#define EP_BIT_HAS_CONTENT (1<<26)
+#define EP_BIT_AMOEBALIVE (1 << 0)
+#define EP_BIT_AMOEBOID (1 << 1)
+#define EP_BIT_SCHLUESSEL (1 << 2)
+#define EP_BIT_PFORTE (1 << 3)
+#define EP_BIT_SOLID (1 << 4)
+#define EP_BIT_MASSIV (1 << 5)
+#define EP_BIT_SLIPPERY (1 << 6)
+#define EP_BIT_ENEMY (1 << 7)
+#define EP_BIT_MAUER (1 << 8)
+#define EP_BIT_CAN_FALL (1 << 9)
+#define EP_BIT_CAN_SMASH (1 << 10)
+#define EP_BIT_CAN_CHANGE (1 << 11)
+#define EP_BIT_CAN_MOVE (1 << 12)
+#define EP_BIT_COULD_MOVE (1 << 13)
+#define EP_BIT_DONT_TOUCH (1 << 14)
+#define EP_BIT_DONT_GO_TO (1 << 15)
+#define EP_BIT_MAMPF2 (1 << 16)
+#define EP_BIT_CHAR (1 << 17)
+#define EP_BIT_BD_ELEMENT (1 << 18)
+#define EP_BIT_SB_ELEMENT (1 << 19)
+#define EP_BIT_GEM (1 << 20)
+#define EP_BIT_INACTIVE (1 << 21)
+#define EP_BIT_EXPLOSIVE (1 << 22)
+#define EP_BIT_MAMPF3 (1 << 23)
+#define EP_BIT_PUSHABLE (1 << 24)
+#define EP_BIT_PLAYER (1 << 25)
+#define EP_BIT_HAS_CONTENT (1 << 26)
+#define EP_BIT_EATABLE (1 << 27)
#define IS_AMOEBALIVE(e) (Elementeigenschaften[e] & EP_BIT_AMOEBALIVE)
#define IS_AMOEBOID(e) (Elementeigenschaften[e] & EP_BIT_AMOEBOID)
#define IS_PUSHABLE(e) (Elementeigenschaften[e] & EP_BIT_PUSHABLE)
#define ELEM_IS_PLAYER(e) (Elementeigenschaften[e] & EP_BIT_PLAYER)
#define HAS_CONTENT(e) (Elementeigenschaften[e] & EP_BIT_HAS_CONTENT)
+#define IS_EATABLE(e) (Elementeigenschaften[e] & EP_BIT_EATABLE)
#define IS_PLAYER(x,y) (ELEM_IS_PLAYER(StorePlayer[x][y]))
/* directions for moving */
#define MV_NO_MOVING 0
-#define MV_LEFT (1<<0)
-#define MV_RIGHT (1<<1)
-#define MV_UP (1<<2)
-#define MV_DOWN (1<<3)
+#define MV_LEFT (1 << 0)
+#define MV_RIGHT (1 << 1)
+#define MV_UP (1 << 2)
+#define MV_DOWN (1 << 3)
/* font types */
#define FS_SMALL 0