rnd-19980927
authorHolger Schemel <info@artsoft.org>
Mon, 28 Sep 1998 03:01:08 +0000 (05:01 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:30:43 +0000 (10:30 +0200)
src/cartoons.c
src/events.c
src/game.c
src/game.h
src/init.c
src/main.c
src/main.h
src/screens.c
src/tools.c
src/tools.h

index 2ffb823dd7246dce890c7fb51deaea276ad6b3d3..4857e06fcc8a59cbb7e78499e5a8b0a76c3b2910 100644 (file)
@@ -131,10 +131,10 @@ void HandleAnimation(int mode)
 
        SetDrawtoField(DRAW_BACKBUFFER);
 
-       for(xx=0;xx<SCR_FIELDX;xx++)
-         for(yy=0;yy<SCR_FIELDY;yy++)
+       for(xx=0; xx<SCR_FIELDX; xx++)
+         for(yy=0; yy<SCR_FIELDY; yy++)
            DrawScreenField(xx,yy);
-       DrawPlayerField(JX,JY);
+       DrawAllPlayers();
 
        SetDrawtoField(DRAW_DIRECT);
       }
@@ -267,8 +267,8 @@ BOOL AnimateToon(int toon_nr, BOOL restart)
     },
     {
       GAMETOON_XSIZE, GAMETOON_YSIZE,
-      ((GFX_SPIELER_LEFT - GFX_START_ROCKSHEROES) % HEROES_PER_LINE)*TILEX,
-      ((GFX_SPIELER_LEFT - GFX_START_ROCKSHEROES) / HEROES_PER_LINE)*TILEY,
+      ((GFX_SPIELER1_LEFT - GFX_START_ROCKSHEROES) % HEROES_PER_LINE)*TILEX,
+      ((GFX_SPIELER1_LEFT - GFX_START_ROCKSHEROES) / HEROES_PER_LINE)*TILEY,
       GAMETOON_FRAMES_4,
       GAMETOON_FPS,
       GAMETOON_STEPSIZE,
@@ -278,8 +278,8 @@ BOOL AnimateToon(int toon_nr, BOOL restart)
     },
     {
       GAMETOON_XSIZE, GAMETOON_YSIZE,
-      ((GFX_SPIELER_RIGHT - GFX_START_ROCKSHEROES) % HEROES_PER_LINE)*TILEX,
-      ((GFX_SPIELER_RIGHT - GFX_START_ROCKSHEROES) / HEROES_PER_LINE)*TILEY,
+      ((GFX_SPIELER1_RIGHT - GFX_START_ROCKSHEROES) % HEROES_PER_LINE)*TILEX,
+      ((GFX_SPIELER1_RIGHT - GFX_START_ROCKSHEROES) / HEROES_PER_LINE)*TILEY,
       GAMETOON_FRAMES_4,
       GAMETOON_FPS,
       GAMETOON_STEPSIZE,
index 039be790270c51f9eb82c11990f3d6986d67d1be..bde68249425127f49c3f6c81a68ee324611b6b41 100644 (file)
@@ -167,11 +167,11 @@ void HandleExposeEvent(XExposeEvent *event)
 
     SetDrawtoField(DRAW_BACKBUFFER);
 
-    for(xx=0;xx<SCR_FIELDX;xx++)
-      for(yy=0;yy<SCR_FIELDY;yy++)
+    for(xx=0; xx<SCR_FIELDX; xx++)
+      for(yy=0; yy<SCR_FIELDY; yy++)
        if (xx>=x1 && xx<=x2 && yy>=y1 && yy<=y2)
          DrawScreenField(xx,yy);
-    DrawPlayerField(JX,JY);
+    DrawAllPlayers();
 
     SetDrawtoField(DRAW_DIRECT);
   }
@@ -267,6 +267,26 @@ void HandleButton(int mx, int my, int button)
     HandleGameButtons(mx,my,button);
   }
 
+#ifdef DEBUG
+  if (game_status == PLAYING && button)
+  {
+    int sx = (mx - SX) / TILEX;
+    int sy = (my - SY) / TILEY;
+
+    if (IN_SCR_FIELD(sx,sy))
+    {
+      int x = UNSCROLLX(sx);
+      int y = UNSCROLLY(sy);
+
+      printf("INFO: Feld[%d][%d] == %d\n", x,y, Feld[x][y]);
+      printf("      Store[%d][%d] == %d\n", x,y, Store[x][y]);
+      printf("      Store2[%d][%d] == %d\n", x,y, Store2[x][y]);
+      printf("      StorePlayer[%d][%d] == %d\n", x,y, StorePlayer[x][y]);
+      printf("\n");
+    }
+  }
+#endif
+
   switch(game_status)
   {
     case MAINMENU:
@@ -438,7 +458,7 @@ void HandleKey(KeySym key, int key_status)
   if (key_status == KEY_RELEASED)
     return;
 
-  if (key==XK_Return && game_status==PLAYING && GameOver)
+  if (key==XK_Return && game_status==PLAYING && AllPlayersGone)
   {
     CloseDoor(DOOR_CLOSE_1);
     game_status = MAINMENU;
@@ -611,6 +631,7 @@ void HandleKey(KeySym key, int key_status)
          break;
 
        case XK_y:
+         /*
          {
            printf("FX = %d, FY = %d\n", FX,FY);
 
@@ -622,6 +643,26 @@ void HandleKey(KeySym key, int key_status)
            XSync(display,FALSE);
            Delay(1000);
          }
+         */
+
+         printf("direct_draw_on == %d\n", direct_draw_on);
+
+         break;
+
+       case XK_z:
+         {
+           int i;
+
+           for(i=0; i<MAX_PLAYERS; i++)
+           {
+             printf("Player %d:\n", i);
+             printf("  jx == %d, jy == %d\n",
+                    stored_player[i].jx, stored_player[i].jy);
+             printf("  last_jx == %d, last_jy == %d\n",
+                    stored_player[i].last_jx, stored_player[i].last_jy);
+           }
+           printf("\n");
+         }
 
          break;
 #endif
@@ -712,7 +753,7 @@ void HandleJoystick()
       if (tape.playing || keyboard)
        newbutton = ((joy & JOY_BUTTON) != 0);
 
-      if (GameOver && newbutton)
+      if (AllPlayersGone && newbutton)
       {
        CloseDoor(DOOR_CLOSE_1);
        game_status = MAINMENU;
@@ -720,7 +761,7 @@ void HandleJoystick()
        return;
       }
 
-      if (tape.pausing || PlayerGone)
+      if (tape.pausing || AllPlayersGone)
        joy = 0;
 
       HandleGameActions(joy);
index fd58165902daf1fb29f4b49747943b541fb28d9b..05af36f92b6a846193002ae345d09d1120cd68ff 100644 (file)
@@ -59,77 +59,80 @@ void GetPlayerConfig()
 
 void InitGame()
 {
-  int i, x,y;
+  int i,j, x,y;
   BOOL emulate_bd = TRUE;      /* unless non-BOULDERDASH elements found */
   BOOL emulate_sb = TRUE;      /* unless non-SOKOBAN     elements found */
 
   for(i=0; i<MAX_PLAYERS; i++)
-    stored_player[i].active = FALSE;
+  {
+    struct PlayerInfo *player = &stored_player[i];
 
-  local_player->nr = 1;
-  local_player->active = TRUE;
-  local_player->local = TRUE;
+    player->nr = i;
+    player->active = FALSE;
+    player->local = FALSE;
 
-  player = local_player;
+    player->score = 0;
+    player->gems_still_needed = level.edelsteine;
+    player->sokobanfields_still_needed = 0;
+    player->lights_still_needed = 0;
+    player->friends_still_needed = 0;
 
-  player->score = 0;
-  player->gems_still_needed = level.edelsteine;
-  player->sokobanfields_still_needed = 0;
-  player->lights_still_needed = 0;
-  player->friends_still_needed = 0;
+    for(j=0; j<4; j++)
+      player->key[j] = FALSE;
 
-  for(i=0; i<4; i++)
-    player->key[i] = FALSE;
+    player->dynamite = 0;
+    player->dynabomb_count = 0;
+    player->dynabomb_size = 0;
+    player->dynabombs_left = 0;
+    player->dynabomb_xl = FALSE;
 
-  player->dynamite = 0;
-  player->dynabomb_count = 0;
-  player->dynabomb_size = 0;
-  player->dynabombs_left = 0;
-  player->dynabomb_xl = FALSE;
+    player->MovDir = MV_NO_MOVING;
+    player->MovPos = 0;
+    player->Pushing = FALSE;
+    player->GfxPos = 0;
+    player->Frame = 0;
 
-  MampferNr = 0;
-  FrameCounter = 0;
-  TimeFrames = 0;
-  TimeLeft = level.time;
-  ScreenMovPos = 0;
+    player->actual_frame_counter = 0;
+
+    player->frame_reset_delay = 0;
 
-  player->MovDir = MV_NO_MOVING;
-  player->MovPos = 0;
-  player->Pushing = FALSE;
-  player->GfxPos = 0;
-  player->Frame = 0;
+    player->push_delay = 0;
+    player->push_delay_value = 5;
 
-  player->frame_reset_delay = 0;
+    player->move_delay = 0;
+    player->last_move_dir = MV_NO_MOVING;
 
-  player->push_delay = 0;
-  player->push_delay_value = 5;
+    player->snapped = FALSE;
 
-  player->move_delay = 0;
-  player->last_move_dir = MV_NO_MOVING;
+    player->gone = FALSE;
 
-  player->lastJX = player->lastJY = 0;
-  player->JX = player->JY = 0;
+    player->last_jx = player->last_jy = 0;
+    player->jx = player->jy = 0;
 
-  lastJX = lastJY = 0;
-  JX = JY = 0;
-  ZX = ZY = -1;
+    DigField(player, 0,0,0,0,DF_NO_PUSH);
+    SnapField(player, 0,0);
 
 
-  /* test */
-  for(i=1; i<MAX_PLAYERS; i++)
-  {
-    stored_player[i] = stored_player[0];
-    stored_player[i].nr = i+1;
+    /* TEST TEST TEST */
     stored_player[i].active = TRUE;
-    stored_player[i].local = FALSE;
+    /* TEST TEST TEST */
+
+    player->LevelSolved = FALSE;
+    player->GameOver = FALSE;
   }
 
+  local_player->active = TRUE;
+  local_player->local = TRUE;
 
+  ZX = ZY = -1;
 
-  PlayerGone = LevelSolved = GameOver = SiebAktiv = FALSE;
+  MampferNr = 0;
+  FrameCounter = 0;
+  TimeFrames = 0;
+  TimeLeft = level.time;
+  ScreenMovPos = 0;
 
-  DigField(0,0,0,0,DF_NO_PUSH);
-  SnapField(0,0);
+  AllPlayersGone = SiebAktiv = FALSE;
 
   for(i=0;i<MAX_NUM_AMOEBA;i++)
     AmoebaCnt[i] = AmoebaCnt2[i] = 0;
@@ -151,30 +154,26 @@ void InitGame()
     switch(Feld[x][y])
     {
       case EL_SPIELFIGUR:
+       Feld[x][y] = EL_SPIELER1;
+       /* no break! */
       case EL_SPIELER1:
-       StorePlayer[x][y] = EL_SPIELER1;
-       Feld[x][y] = EL_LEERRAUM;
-       JX = lastJX = x;
-       JY = lastJY = y;
-
-       player->JX = JX;
-       player->JY = JY;
-       player->lastJX = lastJX;
-       player->lastJY = lastJY;
-
-       break;
       case EL_SPIELER2:
       case EL_SPIELER3:
       case EL_SPIELER4:
-       StorePlayer[x][y] = Feld[x][y];
-       Feld[x][y] = EL_LEERRAUM;
+      {
+       struct PlayerInfo *player = &stored_player[Feld[x][y] - EL_SPIELER1];
+       int jx = player->jx, jy = player->jy;
 
-       stored_player[StorePlayer[x][y] - EL_SPIELER1].JX = x;
-       stored_player[StorePlayer[x][y] - EL_SPIELER1].JY = y;
-       stored_player[StorePlayer[x][y] - EL_SPIELER1].lastJX = x;
-       stored_player[StorePlayer[x][y] - EL_SPIELER1].lastJY = y;
+       /* remove duplicate players */
+       if (StorePlayer[jx][jy] == Feld[x][y])
+         StorePlayer[jx][jy] = 0;
 
+       StorePlayer[x][y] = Feld[x][y];
+       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;
@@ -254,17 +253,19 @@ void InitGame()
                    emulate_sb ? EMU_SOKOBAN : EMU_NONE);
 
   scroll_x = scroll_y = -1;
-  if (JX>=MIDPOSX-1)
-    scroll_x =
-      (JX<=lev_fieldx-MIDPOSX ? JX-MIDPOSX : lev_fieldx-SCR_FIELDX+1);
-  if (JY>=MIDPOSY-1)
-    scroll_y =
-      (JY<=lev_fieldy-MIDPOSY ? JY-MIDPOSY : lev_fieldy-SCR_FIELDY+1);
+  if (local_player->jx >= MIDPOSX-1)
+    scroll_x = (local_player->jx <= lev_fieldx-MIDPOSX ?
+               local_player->jx - MIDPOSX :
+               lev_fieldx - SCR_FIELDX + 1);
+  if (local_player->jy >= MIDPOSY-1)
+    scroll_y = (local_player->jy <= lev_fieldy-MIDPOSY ?
+               local_player->jy - MIDPOSY :
+               lev_fieldy - SCR_FIELDY + 1);
 
   CloseDoor(DOOR_CLOSE_1);
 
   DrawLevel();
-  DrawLevelElement(JX,JY,EL_SPIELFIGUR);
+  DrawAllPlayers();
   FadeToFront();
 
   XCopyArea(display,pix[PIX_DOOR],pix[PIX_DB_DOOR],gc,
@@ -419,7 +420,7 @@ void GameWon()
   int hi_pos;
   int bumplevel = FALSE;
 
-  LevelSolved = FALSE;
+  local_player->LevelSolved = FALSE;
 
   if (TimeLeft)
   {
@@ -730,7 +731,24 @@ void Explode(int ex, int ey, int phase, int mode)
        element = Store2[x][y];
 
       if (IS_PLAYER(ex,ey))
-       Store[x][y] = EL_EDELSTEIN_GELB;
+      {
+       switch(StorePlayer[ex][ey])
+       {
+         case EL_SPIELER2:
+           Store[x][y] = EL_EDELSTEIN_ROT;
+           break;
+         case EL_SPIELER3:
+           Store[x][y] = EL_EDELSTEIN;
+           break;
+         case EL_SPIELER4:
+           Store[x][y] = EL_EDELSTEIN_LILA;
+           break;
+         case EL_SPIELER1:
+         default:
+           Store[x][y] = EL_EDELSTEIN_GELB;
+           break;
+       }
+      }
       else if (center_element==EL_MAULWURF)
        Store[x][y] = EL_EDELSTEIN_ROT;
       else if (center_element==EL_PINGUIN)
@@ -796,7 +814,7 @@ void Explode(int ex, int ey, int phase, int mode)
     int element = Store2[x][y];
 
     if (IS_PLAYER(x,y))
-      KillHero();
+      KillHero(PLAYERINFO(x,y));
     else if (IS_EXPLOSIVE(element))
     {
       Feld[x][y] = Store2[x][y];
@@ -827,9 +845,10 @@ void Explode(int ex, int ey, int phase, int mode)
   }
 }
 
-void DynaExplode(int ex, int ey, int size)
+void DynaExplode(int ex, int ey)
 {
   int i,j;
+  struct PlayerInfo *player = &stored_player[Store2[ex][ey] - EL_SPIELER1];
   static int xy[4][2] =
   {
     { 0,-1 },
@@ -838,11 +857,13 @@ void DynaExplode(int ex, int ey, int size)
     { 0,+1 }
   };
 
+  Store2[ex][ey] = 0;  /* delete player information */
+
   Explode(ex,ey,0,EX_CENTER);
 
   for(i=0;i<4;i++)
   {
-    for(j=1;j<=size;j++)
+    for(j=1; j<=player->dynabomb_size; j++)
     {
       int x = ex+j*xy[i%4][0];
       int y = ey+j*xy[i%4][1];
@@ -888,7 +909,7 @@ void Bang(int x, int y)
     case EL_DYNABOMB_NR:
     case EL_DYNABOMB_SZ:
     case EL_DYNABOMB_XL:
-      DynaExplode(x,y,player->dynabomb_size);
+      DynaExplode(x,y);
       break;
     case EL_BIRNE_AUS:
     case EL_BIRNE_EIN:
@@ -977,7 +998,7 @@ void Impact(int x, int y)
   if (element==EL_TROPFEN && (lastline || object_hit))
   {
     if (object_hit && IS_PLAYER(x,y+1))
-      KillHero();
+      KillHero(PLAYERINFO(x,y+1));
     else if (object_hit && (smashed==EL_MAULWURF || smashed==EL_PINGUIN))
       Bang(x,y+1);
     else
@@ -997,7 +1018,7 @@ void Impact(int x, int y)
 
     if (IS_PLAYER(x,y+1))
     {
-      KillHero();
+      KillHero(PLAYERINFO(x,y+1));
       return;
     }
     else if (smashed==EL_MAULWURF || smashed==EL_PINGUIN)
@@ -1346,14 +1367,32 @@ void TurnRound(int x, int y)
   else if (element==EL_ROBOT || element==EL_SONDE ||
           element==EL_MAULWURF || element==EL_PINGUIN)
   {
-    int attr_x = JX, attr_y = JY;
-    int newx, newy;
+    int attr_x = -1, attr_y = -1;
 
-    if (PlayerGone)
+    if (AllPlayersGone)
     {
       attr_x = ExitX;
       attr_y = ExitY;
     }
+    else
+    {
+      int i;
+
+      for(i=0; i<MAX_PLAYERS; i++)
+      {
+       struct PlayerInfo *player = &stored_player[i];
+       int jx = player->jx, jy = player->jy;
+
+       if (!player->active || player->gone)
+         continue;
+
+       if (attr_x == -1 || ABS(jx-x)+ABS(jy-y) < ABS(attr_x-x)+ABS(attr_y-y))
+       {
+         attr_x = jx;
+         attr_y = jy;
+       }
+      }
+    }
 
     if (element==EL_ROBOT && ZX>=0 && ZY>=0)
     {
@@ -1374,8 +1413,8 @@ void TurnRound(int x, int y)
 
       for(i=0;i<4;i++)
       {
-       int ex = x+xy[i%4][0];
-       int ey = y+xy[i%4][1];
+       int ex = x + xy[i%4][0];
+       int ey = y + xy[i%4][1];
 
        if (IN_LEV_FIELD(ex,ey) && Feld[ex][ey] == EL_AUSGANG_AUF)
        {
@@ -1388,16 +1427,18 @@ void TurnRound(int x, int y)
 
     MovDir[x][y] = MV_NO_MOVING;
     if (attr_x<x)
-      MovDir[x][y] |= (GameOver ? MV_RIGHT : MV_LEFT);
+      MovDir[x][y] |= (AllPlayersGone ? MV_RIGHT : MV_LEFT);
     else if (attr_x>x)
-      MovDir[x][y] |= (GameOver ? MV_LEFT : MV_RIGHT);
+      MovDir[x][y] |= (AllPlayersGone ? MV_LEFT : MV_RIGHT);
     if (attr_y<y)
-      MovDir[x][y] |= (GameOver ? MV_DOWN : MV_UP);
+      MovDir[x][y] |= (AllPlayersGone ? MV_DOWN : MV_UP);
     else if (attr_y>y)
-      MovDir[x][y] |= (GameOver ? MV_UP : MV_DOWN);
+      MovDir[x][y] |= (AllPlayersGone ? MV_UP : MV_DOWN);
 
     if (element==EL_ROBOT)
     {
+      int newx, newy;
+
       if ((MovDir[x][y]&(MV_LEFT|MV_RIGHT)) && (MovDir[x][y]&(MV_UP|MV_DOWN)))
        MovDir[x][y] &= (RND(2) ? (MV_LEFT|MV_RIGHT) : (MV_UP|MV_DOWN));
       Moving2Blocked(x,y,&newx,&newy);
@@ -1409,6 +1450,8 @@ void TurnRound(int x, int y)
     }
     else
     {
+      int newx, newy;
+
       MovDelay[x][y] = 1;
 
       if ((MovDir[x][y]&(MV_LEFT|MV_RIGHT)) && (MovDir[x][y]&(MV_UP|MV_DOWN)))
@@ -1463,14 +1506,15 @@ void StartMoving(int x, int y)
 
       for(i=0; i<MAX_PLAYERS; i++)
       {
-       struct PlayerInfo *pl = &stored_player[i];
+       struct PlayerInfo *player = &stored_player[i];
 
-       if (pl->active && pl->Pushing && pl->MovPos)
+       if (player->active && !player->gone &&
+           player->Pushing && player->MovPos)
        {
-         int nextJX = pl->JX + (pl->JX - pl->lastJX);
-         int nextJY = pl->JY + (pl->JY - pl->lastJY);
+         int next_jx = player->jx + (player->jx - player->last_jx);
+         int next_jy = player->jy + (player->jy - player->last_jy);
 
-         if (x == nextJX && y == nextJY)
+         if (x == next_jx && y == next_jy)
            return;
        }
       }
@@ -1700,7 +1744,7 @@ void StartMoving(int x, int y)
     {
       /* Spieler erwischt */
       MovDir[x][y] = 0;
-      KillHero();
+      KillHero(PLAYERINFO(newx,newy));
       return;
     }
     else if ((element == EL_MAULWURF || element == EL_PINGUIN ||
@@ -1724,14 +1768,15 @@ void StartMoving(int x, int y)
          DrawGraphicThruMask(SCROLLX(newx),SCROLLY(newy),el2gfx(element));
 
        local_player->friends_still_needed--;
-       if (!local_player->friends_still_needed && PlayerGone && !GameOver)
-         LevelSolved = GameOver = TRUE;
+       if (!local_player->friends_still_needed &&
+           !local_player->GameOver && AllPlayersGone)
+         local_player->LevelSolved = local_player->GameOver = TRUE;
 
        return;
       }
       else if (IS_MAMPF3(Feld[newx][newy]))
       {
-       if (DigField(newx,newy, 0,0, DF_DIG) == MF_MOVING)
+       if (DigField(local_player, newx,newy, 0,0, DF_DIG) == MF_MOVING)
          DrawLevelField(newx,newy);
        else
          MovDir[x][y] = MV_NO_MOVING;
@@ -1863,14 +1908,15 @@ void StartMoving(int x, int y)
        /* check if this element is just being pushed */
        for(i=0; i<MAX_PLAYERS; i++)
        {
-         struct PlayerInfo *pl = &stored_player[i];
+         struct PlayerInfo *player = &stored_player[i];
 
-         if (pl->active && pl->Pushing && pl->GfxPos)
+         if (player->active && !player->gone &&
+             player->Pushing && player->GfxPos)
          {
-           int nextJX = pl->JX + (pl->JX - pl->lastJX);
-           int nextJY = pl->JY + (pl->JY - pl->lastJY);
+           int next_jx = player->jx + (player->jx - player->last_jx);
+           int next_jy = player->jy + (player->jy - player->last_jy);
 
-           if (x == nextJX && y == nextJY)
+           if (x == next_jx && y == next_jy)
              return;
          }
        }
@@ -1972,7 +2018,7 @@ void ContinueMoving(int x, int y)
 
     if (DONT_TOUCH(element))   /* Käfer oder Flieger */
     {
-      TestIfBadThingHitsHero();
+      TestIfBadThingHitsHero(newx,newy);
       TestIfBadThingHitsFriend(newx,newy);
       TestIfBadThingHitsOtherBadThing(newx,newy);
     }
@@ -2441,10 +2487,11 @@ void AusgangstuerPruefen(int x, int y)
   {
     Feld[x][y] = EL_AUSGANG_ACT;
 
-    if (IN_SCR_FIELD(SCROLLX(x),SCROLLY(y)))
-      PlaySoundLevel(x,y,SND_OEFFNEN);
-    else
-      PlaySoundLevel(JX,JY,SND_OEFFNEN);
+    PlaySoundLevel(x < UNSCROLLX(BX1) ? UNSCROLLX(BX1) :
+                  (x > UNSCROLLX(BX2) ? UNSCROLLX(BX2) : x),
+                  y < UNSCROLLY(BY1) ? UNSCROLLY(BY1) :
+                  (y > UNSCROLLY(BY2) ? UNSCROLLY(BY2) : y),
+                  SND_OEFFNEN);
   }
 }
 
@@ -2500,31 +2547,20 @@ void EdelsteinFunkeln(int x, int y)
 
       if (MovDelay[x][y])
       {
-       int src_x,src_y, dest_x,dest_y;
        int phase = (MovDelay[x][y]-1)/2;
 
        if (phase > 2)
          phase = 4-phase;
 
-       src_x  = SX + GFX_PER_LINE*TILEX;
-       src_y  = SY + phase*TILEY;
-       dest_x = FX + SCROLLX(x)*TILEX;
-       dest_y = FY + SCROLLY(y)*TILEY;
-
-       /*
-       XSetClipOrigin(display,clip_gc[PIX_BACK],dest_x-src_x,dest_y-src_y);
-       XCopyArea(display,pix[PIX_BACK],drawto_field,clip_gc[PIX_BACK],
-                 src_x,src_y, TILEX,TILEY, dest_x,dest_y);
-                 */
-
-       XSetClipMask(display, tile_clip_gc,
-                    tile_clipmask[GFX_MASK_SPARKLING + phase]);
-       XSetClipOrigin(display, tile_clip_gc, dest_x,dest_y);
-       XCopyArea(display, pix[PIX_BACK], drawto_field, tile_clip_gc,
-                 src_x,src_y, TILEX,TILEY, dest_x,dest_y);
+       DrawGraphicThruMask(SCROLLX(x),SCROLLY(y), GFX_FUNKELN_WEISS + phase);
 
        if (direct_draw_on)
        {
+         int dest_x,dest_y;
+
+         dest_x = FX + SCROLLX(x)*TILEX;
+         dest_y = FY + SCROLLY(y)*TILEY;
+
          XCopyArea(display,drawto_field,window,gc,
                    dest_x,dest_y, TILEX,TILEY, dest_x,dest_y);
          SetDrawtoField(DRAW_DIRECT);
@@ -2667,9 +2703,10 @@ void CheckForDragon(int x, int y)
   }
 }
 
-void PlayerActions(int player_action)
+void PlayerActions(struct PlayerInfo *player, int player_action)
 {
   BOOL moved = FALSE, snapped = FALSE, bombed = FALSE;
+  int jx = player->jx, jy = player->jy;
   int left     = player_action & JOY_LEFT;
   int right    = player_action & JOY_RIGHT;
   int up       = player_action & JOY_UP;
@@ -2679,17 +2716,20 @@ void PlayerActions(int player_action)
   int dx       = (left ? -1    : right ? 1     : 0);
   int dy       = (up   ? -1    : down  ? 1     : 0);
 
+  if (!player->active || player->gone)
+    return;
+
   if (player_action)
   {
     player->frame_reset_delay = 0;
 
     if (button1)
-      snapped = SnapField(dx,dy);
+      snapped = SnapField(player, dx,dy);
     else
     {
       if (button2)
-       bombed = PlaceBomb();
-      moved = MoveFigure(dx,dy);
+       bombed = PlaceBomb(player);
+      moved = MoveFigure(player, dx,dy);
     }
 
     if (tape.recording && (moved || snapped || bombed))
@@ -2699,12 +2739,12 @@ void PlayerActions(int player_action)
       TapeRecordAction(player_action);
     }
     else if (tape.playing && snapped)
-      SnapField(0,0);                  /* stop snapping */
+      SnapField(player, 0,0);                  /* stop snapping */
   }
   else
   {
-    DigField(0,0,0,0,DF_NO_PUSH);
-    SnapField(0,0);
+    DigField(player, 0,0, 0,0, DF_NO_PUSH);
+    SnapField(player, 0,0);
     if (++player->frame_reset_delay > MoveSpeed)
       player->Frame = 0;
   }
@@ -2718,9 +2758,9 @@ void PlayerActions(int player_action)
     {
       int dx = (next_joy == JOY_LEFT ? -1 : +1);
 
-      if (IN_LEV_FIELD(JX+dx,JY) && IS_PUSHABLE(Feld[JX+dx][JY]))
+      if (IN_LEV_FIELD(jx+dx,jy) && IS_PUSHABLE(Feld[jx+dx][jy]))
       {
-       int el = Feld[JX+dx][JY];
+       int el = Feld[jx+dx][jy];
        int push_delay = (IS_SB_ELEMENT(el) || el==EL_SONDE ? 2 : 10);
 
        if (tape.delay_played + push_delay >= tape.pos[tape.counter].delay)
@@ -2757,27 +2797,10 @@ void GameActions(int player_action)
 
   for(i=0; i<MAX_PLAYERS; i++)
   {
-    player = &stored_player[i];
-    JX = player->JX;
-    JY = player->JY;
-    lastJX = player->lastJX;
-    lastJY = player->lastJY;
-
-    if (!player->active)
-      continue;
-
-    PlayerActions(player_action);
-
-    if (player->MovPos)
-      ScrollFigure(0);
+    PlayerActions(&stored_player[i], player_action);
+    ScrollFigure(&stored_player[i], SCROLL_FIGURE_GO_ON);
   }
 
-  player = local_player;
-  JX = player->JX;
-  JY = player->JY;
-  lastJX = player->lastJX;
-  lastJY = player->lastJY;
-
   if (tape.pausing || (tape.playing && !TapePlayDelay()))
     return;
   else if (tape.recording)
@@ -2859,6 +2882,7 @@ void GameActions(int player_action)
     if (SiebAktiv)
     {
       BOOL sieb = FALSE;
+      int jx = local_player->jx, jy = local_player->jy;
 
       if (element==EL_SIEB_LEER || element==EL_SIEB_VOLL ||
          Store[x][y]==EL_SIEB_LEER)
@@ -2873,7 +2897,8 @@ void GameActions(int player_action)
        sieb = TRUE;
       }
 
-      if (sieb && ABS(x-JX)+ABS(y-JY) < ABS(sieb_x-JX)+ABS(sieb_y-JY))
+      /* 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))
       {
        sieb_x = x;
        sieb_y = y;
@@ -2919,35 +2944,11 @@ void GameActions(int player_action)
     DrawText(DX_TIME,DY_TIME,int2str(TimeLeft,3),FS_SMALL,FC_YELLOW);
 
     if (!TimeLeft)
-      KillHero();
-  }
-
-
-
-
-  for(i=0; i<MAX_PLAYERS; i++)
-  {
-    player = &stored_player[i];
-    JX = player->JX;
-    JY = player->JY;
-    lastJX = player->lastJX;
-    lastJY = player->lastJY;
-
-    if (!player->active)
-      continue;
-
-    DrawPlayerField(player->JX,player->JY);
+      for(i=0; i<MAX_PLAYERS; i++)
+       KillHero(&stored_player[i]);
   }
 
-  player = local_player;
-  JX = player->JX;
-  JY = player->JY;
-  lastJX = player->lastJX;
-  lastJY = player->lastJY;
-
-  /*
-  DrawPlayerField(JX,JY);
-  */
+  DrawAllPlayers();
 }
 
 void ScrollLevel(int dx, int dy)
@@ -2955,7 +2956,7 @@ void ScrollLevel(int dx, int dy)
   int softscroll_offset = (soft_scrolling_on ? TILEX : 0);
   int x,y;
 
-  ScreenMovPos = player->GfxPos;
+  ScreenMovPos = local_player->GfxPos;
 
   XCopyArea(display,drawto_field,drawto_field,gc,
            FX + TILEX*(dx==-1) - softscroll_offset,
@@ -2981,13 +2982,15 @@ void ScrollLevel(int dx, int dy)
   redraw_mask |= REDRAW_FIELD;
 }
 
-BOOL MoveFigureOneStep(int dx, int dy, int real_dx, int real_dy)
+BOOL MoveFigureOneStep(struct PlayerInfo *player,
+                      int dx, int dy, int real_dx, int real_dy)
 {
-  int newJX = JX+dx, newJY = JY+dy;
+  int jx = player->jx, jy = player->jy;
+  int new_jx = jx+dx, new_jy = jy+dy;
   int element;
   int can_move;
 
-  if (PlayerGone || (!dx && !dy))
+  if (player->gone || (!dx && !dy))
     return(MF_NO_ACTION);
 
   player->MovDir = (dx < 0 ? MV_LEFT :
@@ -2995,53 +2998,53 @@ BOOL MoveFigureOneStep(int dx, int dy, int real_dx, int real_dy)
                    dy < 0 ? MV_UP :
                    dy > 0 ? MV_DOWN :  MV_NO_MOVING);
 
-  if (!IN_LEV_FIELD(newJX,newJY))
+  if (!IN_LEV_FIELD(new_jx,new_jy))
     return(MF_NO_ACTION);
 
-  element = MovingOrBlocked2Element(newJX,newJY);
+  element = MovingOrBlocked2Element(new_jx,new_jy);
 
   if (DONT_GO_TO(element))
   {
     if (element==EL_SALZSAEURE && dx==0 && dy==1)
     {
-      Blurb(JX,JY);
-      Feld[JX][JY] = EL_SPIELFIGUR;
-      InitMovingField(JX,JY,MV_DOWN);
-      Store[JX][JY] = EL_SALZSAEURE;
-      ContinueMoving(JX,JY);
-      BuryHero();
+      Blurb(jx,jy);
+      Feld[jx][jy] = EL_SPIELFIGUR;
+      InitMovingField(jx,jy,MV_DOWN);
+      Store[jx][jy] = EL_SALZSAEURE;
+      ContinueMoving(jx,jy);
+      BuryHero(player);
     }
     else
-      KillHero();
+      KillHero(player);
 
     return(MF_MOVING);
   }
 
-  can_move = DigField(newJX,newJY, real_dx,real_dy, DF_DIG);
+  can_move = DigField(player, new_jx,new_jy, real_dx,real_dy, DF_DIG);
   if (can_move != MF_MOVING)
     return(can_move);
 
-  lastJX = player->lastJX = JX;
-  lastJY = player->lastJY = JY;
-  JX = player->JX = newJX;
-  JY = player->JY = newJY;
-
-  StorePlayer[lastJX][lastJY] = EL_LEERRAUM;
-  StorePlayer[JX][JY] = EL_SPIELER1;
+  StorePlayer[jx][jy] = EL_LEERRAUM;
+  player->last_jx = jx;
+  player->last_jy = jy;
+  jx = player->jx = new_jx;
+  jy = player->jy = new_jy;
+  StorePlayer[jx][jy] = EL_SPIELER1 + player->nr;
 
   player->MovPos = (dx > 0 || dy > 0 ? -1 : 1) * 7*TILEX/8;
 
-  ScrollFigure(-1);
+  ScrollFigure(player, SCROLL_FIGURE_INIT);
 
   return(MF_MOVING);
 }
 
-BOOL MoveFigure(int dx, int dy)
+BOOL MoveFigure(struct PlayerInfo *player, int dx, int dy)
 {
+  int jx = player->jx, jy = player->jy;
+  int old_jx = jx, old_jy = jy;
   int moved = MF_NO_ACTION;
-  int oldJX = JX, oldJY = JY;
 
-  if (PlayerGone || (!dx && !dy))
+  if (player->gone || (!dx && !dy))
     return(FALSE);
 
   if (!FrameReached(&player->move_delay,MoveSpeed) && !tape.playing)
@@ -3049,32 +3052,29 @@ BOOL MoveFigure(int dx, int dy)
 
   if (player->last_move_dir & (MV_LEFT | MV_RIGHT))
   {
-    if (!(moved |= MoveFigureOneStep(0,dy, dx,dy)))
-      moved |= MoveFigureOneStep(dx,0, dx,dy);
+    if (!(moved |= MoveFigureOneStep(player, 0,dy, dx,dy)))
+      moved |= MoveFigureOneStep(player, dx,0, dx,dy);
   }
   else
   {
-    if (!(moved |= MoveFigureOneStep(dx,0, dx,dy)))
-      moved |= MoveFigureOneStep(0,dy, dx,dy);
+    if (!(moved |= MoveFigureOneStep(player, dx,0, dx,dy)))
+      moved |= MoveFigureOneStep(player, 0,dy, dx,dy);
   }
 
-
-  /*
-  player->last_move_dir = MV_NO_MOVING;
-  */
-
+  jx = player->jx;
+  jy = player->jy;
 
   if (moved & MF_MOVING && player == local_player)
   {
     int old_scroll_x = scroll_x, old_scroll_y = scroll_y;
     int offset = (scroll_delay_on ? 3 : 0);
 
-    if ((scroll_x < JX-MIDPOSX-offset || scroll_x > JX-MIDPOSX+offset) &&
-       JX >= MIDPOSX-1-offset && JX <= lev_fieldx-(MIDPOSX-offset))
-      scroll_x = JX-MIDPOSX + (scroll_x < JX-MIDPOSX ? -offset : offset);
-    if ((scroll_y < JY-MIDPOSY-offset || scroll_y > JY-MIDPOSY+offset) &&
-       JY >= MIDPOSY-1-offset && JY <= lev_fieldy-(MIDPOSY-offset))
-      scroll_y = JY-MIDPOSY + (scroll_y < JY-MIDPOSY ? -offset : offset);
+    if ((scroll_x < jx-MIDPOSX-offset || scroll_x > jx-MIDPOSX+offset) &&
+       jx >= MIDPOSX-1-offset && jx <= lev_fieldx-(MIDPOSX-offset))
+      scroll_x = jx-MIDPOSX + (scroll_x < jx-MIDPOSX ? -offset : offset);
+    if ((scroll_y < jy-MIDPOSY-offset || scroll_y > jy-MIDPOSY+offset) &&
+       jy >= MIDPOSY-1-offset && jy <= lev_fieldy-(MIDPOSY-offset))
+      scroll_y = jy-MIDPOSY + (scroll_y < jy-MIDPOSY ? -offset : offset);
 
     if (scroll_x != old_scroll_x || scroll_y != old_scroll_y)
       ScrollLevel(old_scroll_x - scroll_x, old_scroll_y - scroll_y);
@@ -3087,41 +3087,46 @@ BOOL MoveFigure(int dx, int dy)
 
   if (moved & MF_MOVING)
   {
-    if (oldJX != JX && oldJY == JY)
-      player->MovDir = (oldJX < JX ? MV_RIGHT : MV_LEFT);
-    else if (oldJX == JX && oldJY != JY)
-      player->MovDir = (oldJY < JY ? MV_DOWN : MV_UP);
+    if (old_jx != jx && old_jy == jy)
+      player->MovDir = (old_jx < jx ? MV_RIGHT : MV_LEFT);
+    else if (old_jx == jx && old_jy != jy)
+      player->MovDir = (old_jy < jy ? MV_DOWN : MV_UP);
 
-    DrawLevelField(JX,JY);     /* für "ErdreichAnbroeckeln()" */
+    DrawLevelField(jx,jy);     /* für "ErdreichAnbroeckeln()" */
 
     player->last_move_dir = player->MovDir;
   }
+  else
+    player->last_move_dir = MV_NO_MOVING;
 
-  TestIfHeroHitsBadThing();
+  TestIfHeroHitsBadThing(jx,jy);
 
-  if (PlayerGone)
-    RemoveHero();
+  if (player->gone)
+    RemoveHero(player);
 
   return(moved);
 }
 
-void ScrollFigure(int init)
+void ScrollFigure(struct PlayerInfo *player, int mode)
 {
-  static long actual_frame_counter = 0;
+  int jx = player->jx, jy = player->jy;
+  int last_jx = player->last_jx, last_jy = player->last_jy;
 
-  if (init)
-  {
-    actual_frame_counter = FrameCounter;
+  if (!player->active || player->gone || !player->MovPos)
+    return;
 
+  if (mode == SCROLL_FIGURE_INIT)
+  {
+    player->actual_frame_counter = FrameCounter;
     player->GfxPos = ScrollStepSize * (player->MovPos / ScrollStepSize);
 
-    if (Feld[lastJX][lastJY] == EL_LEERRAUM)
-      Feld[lastJX][lastJY] = EL_PLAYER_IS_LEAVING;
+    if (Feld[last_jx][last_jy] == EL_LEERRAUM)
+      Feld[last_jx][last_jy] = EL_PLAYER_IS_LEAVING;
 
-    DrawPlayerField(JX,JY);
+    DrawPlayer(player);
     return;
   }
-  else if (!FrameReached(&actual_frame_counter,1))
+  else if (!FrameReached(&player->actual_frame_counter,1))
     return;
 
   player->MovPos += (player->MovPos > 0 ? -1 : 1) * TILEX/8;
@@ -3133,15 +3138,15 @@ void ScrollFigure(int init)
     redraw_mask |= REDRAW_FIELD;
   }
 
-  if (Feld[lastJX][lastJY] == EL_PLAYER_IS_LEAVING)
-    Feld[lastJX][lastJY] = EL_LEERRAUM;
+  if (Feld[last_jx][last_jy] == EL_PLAYER_IS_LEAVING)
+    Feld[last_jx][last_jy] = EL_LEERRAUM;
 
-  DrawPlayerField(JX,JY);
+  DrawPlayer(player);
 
   if (!player->MovPos)
   {
-    lastJX = JX;
-    lastJY = JY;
+    player->last_jx = jx;
+    player->last_jy = jy;
   }
 }
 
@@ -3163,12 +3168,12 @@ void TestIfGoodThingHitsBadThing(int goodx, int goody)
     MV_DOWN
   };
 
-  for(i=0;i<4;i++)
+  for(i=0; i<4; i++)
   {
-    int x,y,element;
+    int x,y, element;
 
-    x = goodx+xy[i][0];
-    y = goody+xy[i][1];
+    x = goodx + xy[i][0];
+    y = goody + xy[i][1];
     if (!IN_LEV_FIELD(x,y))
       continue;
 
@@ -3176,7 +3181,7 @@ void TestIfGoodThingHitsBadThing(int goodx, int goody)
 
     if (DONT_TOUCH(element))
     {
-      if (MovDir[x][y]==harmless[i])
+      if (MovDir[x][y] == harmless[i])
        continue;
 
       killx = x;
@@ -3185,10 +3190,10 @@ void TestIfGoodThingHitsBadThing(int goodx, int goody)
     }
   }
 
-  if (killx!=goodx || killy!=goody)
+  if (killx != goodx || killy != goody)
   {
     if (IS_PLAYER(goodx,goody))
-      KillHero();
+      KillHero(PLAYERINFO(goodx,goody));
     else
       Bang(goodx,goody);
   }
@@ -3212,20 +3217,26 @@ void TestIfBadThingHitsGoodThing(int badx, int bady)
     MV_DOWN
   };
 
-  for(i=0;i<4;i++)
+  for(i=0; i<4; i++)
   {
-    int x,y,element;
+    int x,y, element;
 
-    x = badx+xy[i][0];
-    y = bady+xy[i][1];
+    x = badx + xy[i][0];
+    y = bady + xy[i][1];
     if (!IN_LEV_FIELD(x,y))
       continue;
 
     element = Feld[x][y];
 
-    if (element==EL_PINGUIN)
+    if (IS_PLAYER(x,y))
+    {
+      killx = x;
+      killy = y;
+      break;
+    }
+    else if (element == EL_PINGUIN)
     {
-      if (MovDir[x][y]==harmless[i] && IS_MOVING(x,y))
+      if (MovDir[x][y] == harmless[i] && IS_MOVING(x,y))
        continue;
 
       killx = x;
@@ -3234,19 +3245,27 @@ void TestIfBadThingHitsGoodThing(int badx, int bady)
     }
   }
 
-  if (killx!=badx || killy!=bady)
-    Bang(killx,killy);
+  if (killx != badx || killy != bady)
+  {
+    if (IS_PLAYER(killx,killy))
+      KillHero(PLAYERINFO(killx,killy));
+    else
+      Bang(killx,killy);
+  }
 }
 
-void TestIfHeroHitsBadThing()
+void TestIfHeroHitsBadThing(int x, int y)
 {
-  TestIfGoodThingHitsBadThing(JX,JY);
+  TestIfGoodThingHitsBadThing(x,y);
 }
 
-void TestIfBadThingHitsHero()
+void TestIfBadThingHitsHero(int x, int y)
 {
+  /*
   TestIfGoodThingHitsBadThing(JX,JY);
-  /* (no typo!) */
+  */
+
+  TestIfBadThingHitsGoodThing(x,y);
 }
 
 void TestIfFriendHitsBadThing(int x, int y)
@@ -3261,7 +3280,7 @@ void TestIfBadThingHitsFriend(int x, int y)
 
 void TestIfBadThingHitsOtherBadThing(int badx, int bady)
 {
-  int i, killx=badx, killy=bady;
+  int i, killx = badx, killy = bady;
   static int xy[4][2] =
   {
     { 0,-1 },
@@ -3270,65 +3289,81 @@ void TestIfBadThingHitsOtherBadThing(int badx, int bady)
     { 0,+1 }
   };
 
-  for(i=0;i<4;i++)
+  for(i=0; i<4; i++)
   {
-    int x,y,element;
+    int x,y, element;
 
-    x=badx+xy[i][0];
-    y=bady+xy[i][1];
+    x=badx + xy[i][0];
+    y=bady + xy[i][1];
     if (!IN_LEV_FIELD(x,y))
       continue;
 
-    element=Feld[x][y];
-    if (IS_AMOEBOID(element) || element==EL_LIFE ||
-       element==EL_AMOEBING || element==EL_TROPFEN)
+    element = Feld[x][y];
+    if (IS_AMOEBOID(element) || element == EL_LIFE ||
+       element == EL_AMOEBING || element == EL_TROPFEN)
     {
-      killx=x;
-      killy=y;
+      killx = x;
+      killy = y;
       break;
     }
   }
 
-  if (killx!=badx || killy!=bady)
+  if (killx != badx || killy != bady)
     Bang(badx,bady);
 }
 
-void KillHero()
+void KillHero(struct PlayerInfo *player)
 {
-  if (PlayerGone)
+  int jx = player->jx, jy = player->jy;
+
+  if (player->gone)
     return;
 
-  if (IS_PFORTE(Feld[JX][JY]))
-    Feld[JX][JY] = EL_LEERRAUM;
+  if (IS_PFORTE(Feld[jx][jy]))
+    Feld[jx][jy] = EL_LEERRAUM;
 
-  Bang(JX,JY);
-  BuryHero();
+  Bang(jx,jy);
+  BuryHero(player);
 }
 
-void BuryHero()
+void BuryHero(struct PlayerInfo *player)
 {
-  if (PlayerGone)
+  int jx = player->jx, jy = player->jy;
+
+  if (player->gone)
     return;
 
-  PlaySoundLevel(JX,JY,SND_AUTSCH);
-  PlaySoundLevel(JX,JY,SND_LACHEN);
+  PlaySoundLevel(jx,jy, SND_AUTSCH);
+  PlaySoundLevel(jx,jy, SND_LACHEN);
 
-  GameOver = TRUE;
-  RemoveHero();
+  player->GameOver = TRUE;
+  RemoveHero(player);
 }
 
-void RemoveHero()
+void RemoveHero(struct PlayerInfo *player)
 {
-  PlayerGone = TRUE;
+  int jx = player->jx, jy = player->jy;
+  int i, found = FALSE;
+
+  player->gone = TRUE;
+  StorePlayer[jx][jy] = 0;
+
+  for(i=0; i<MAX_PLAYERS; i++)
+    if (stored_player[i].active && !stored_player[i].gone)
+      found = TRUE;
 
-  ExitX = ZX = JX;
-  ExitY = ZY = JY;
-  JX = JY = -1;
+  if (!found)
+    AllPlayersGone = TRUE;
+
+  ExitX = ZX = jx;
+  ExitY = ZY = jy;
 }
 
-int DigField(int x, int y, int real_dx, int real_dy, int mode)
+int DigField(struct PlayerInfo *player,
+            int x, int y, int real_dx, int real_dy, int mode)
 {
-  int dx = x-JX, dy = y-JY;
+  int jx = player->jx, jy = player->jy;
+  int dx = x - jx, dy = y - jy;
   int element;
 
   if (!player->MovPos)
@@ -3451,12 +3486,12 @@ int DigField(int x, int y, int real_dx, int real_dy, int mode)
 
       player->Pushing = TRUE;
 
-      if (!IN_LEV_FIELD(x+dx,y+dy) || Feld[x+dx][y+dy] != EL_LEERRAUM)
+      if (!IN_LEV_FIELD(x+dx,y+dy) || !IS_FREE(x+dx,y+dy))
        return(MF_NO_ACTION);
 
       if (real_dy)
       {
-       if (IN_LEV_FIELD(JX,JY+real_dy) && !IS_SOLID(Feld[JX][JY+real_dy]))
+       if (IN_LEV_FIELD(jx,jy+real_dy) && !IS_SOLID(Feld[jx][jy+real_dy]))
          return(MF_NO_ACTION);
       }
 
@@ -3506,11 +3541,11 @@ int DigField(int x, int y, int real_dx, int real_dy, int mode)
       if (mode==DF_SNAP)
        return(MF_NO_ACTION);
 
-      PlayerGone = TRUE;
+      player->gone = TRUE;
       PlaySoundLevel(x,y,SND_BUING);
 
       if (!local_player->friends_still_needed)
-       LevelSolved = GameOver = TRUE;
+       player->LevelSolved = player->GameOver = TRUE;
 
       break;
 
@@ -3543,19 +3578,19 @@ int DigField(int x, int y, int real_dx, int real_dy, int mode)
       player->Pushing = TRUE;
 
       if (!IN_LEV_FIELD(x+dx,y+dy)
-         || (Feld[x+dx][y+dy] != EL_LEERRAUM
+         || (!IS_FREE(x+dx,y+dy)
              && (Feld[x+dx][y+dy] != EL_SOKOBAN_FELD_LEER
                  || !IS_SB_ELEMENT(element))))
        return(MF_NO_ACTION);
 
       if (dx && real_dy)
       {
-       if (IN_LEV_FIELD(JX,JY+real_dy) && !IS_SOLID(Feld[JX][JY+real_dy]))
+       if (IN_LEV_FIELD(jx,jy+real_dy) && !IS_SOLID(Feld[jx][jy+real_dy]))
          return(MF_NO_ACTION);
       }
       else if (dy && real_dx)
       {
-       if (IN_LEV_FIELD(JX+real_dx,JY) && !IS_SOLID(Feld[JX+real_dx][JY]))
+       if (IN_LEV_FIELD(jx+real_dx,jy) && !IS_SOLID(Feld[jx+real_dx][jy]))
          return(MF_NO_ACTION);
       }
 
@@ -3601,7 +3636,7 @@ int DigField(int x, int y, int real_dx, int real_dy, int mode)
          local_player->sokobanfields_still_needed == 0 &&
          game_emulation == EMU_SOKOBAN)
       {
-       LevelSolved = GameOver = TRUE;
+       player->LevelSolved = player->GameOver = TRUE;
        PlaySoundLevel(x,y,SND_BUING);
       }
 
@@ -3623,21 +3658,24 @@ int DigField(int x, int y, int real_dx, int real_dy, int mode)
   return(MF_MOVING);
 }
 
-BOOL SnapField(int dx, int dy)
+BOOL SnapField(struct PlayerInfo *player, int dx, int dy)
 {
-  int x = JX+dx, y = JY+dy;
-  static int snapped = FALSE;
+  int jx = player->jx, jy = player->jy;
+  int x = jx + dx, y = jy + dy;
 
-  if (PlayerGone || !IN_LEV_FIELD(x,y))
+  if (player->gone || !IN_LEV_FIELD(x,y))
     return(FALSE);
+
   if (dx && dy)
     return(FALSE);
+
   if (!dx && !dy)
   {
-    snapped = FALSE;
+    player->snapped = FALSE;
     return(FALSE);
   }
-  if (snapped)
+
+  if (player->snapped)
     return(FALSE);
 
   player->MovDir = (dx < 0 ? MV_LEFT :
@@ -3645,47 +3683,49 @@ BOOL SnapField(int dx, int dy)
                    dy < 0 ? MV_UP :
                    dy > 0 ? MV_DOWN :  MV_NO_MOVING);
 
-  if (!DigField(x,y, 0,0, DF_SNAP))
+  if (!DigField(player, x,y, 0,0, DF_SNAP))
     return(FALSE);
 
-  snapped = TRUE;
+  player->snapped = TRUE;
   DrawLevelField(x,y);
   BackToFront();
 
   return(TRUE);
 }
 
-BOOL PlaceBomb(void)
+BOOL PlaceBomb(struct PlayerInfo *player)
 {
+  int jx = player->jx, jy = player->jy;
   int element;
 
-  if (PlayerGone || player->MovPos)
+  if (player->gone || player->MovPos)
     return(FALSE);
 
-  element = Feld[JX][JY];
+  element = Feld[jx][jy];
 
   if ((player->dynamite==0 && player->dynabombs_left==0) ||
       element==EL_DYNAMIT || element==EL_DYNABOMB || element==EL_EXPLODING)
     return(FALSE);
 
   if (element != EL_LEERRAUM)
-    Store[JX][JY] = element;
+    Store[jx][jy] = element;
 
   if (player->dynamite)
   {
-    Feld[JX][JY] = EL_DYNAMIT;
-    MovDelay[JX][JY] = 96;
+    Feld[jx][jy] = EL_DYNAMIT;
+    MovDelay[jx][jy] = 96;
     player->dynamite--;
     DrawText(DX_DYNAMITE, DY_DYNAMITE, int2str(local_player->dynamite, 3),
             FS_SMALL, FC_YELLOW);
-    DrawGraphicThruMask(SCROLLX(JX),SCROLLY(JY),GFX_DYNAMIT);
+    DrawGraphicThruMask(SCROLLX(jx),SCROLLY(jy),GFX_DYNAMIT);
   }
   else
   {
-    Feld[JX][JY] = EL_DYNABOMB;
-    MovDelay[JX][JY] = 96;
+    Feld[jx][jy] = EL_DYNABOMB;
+    Store2[jx][jy] = EL_SPIELER1 + player->nr; /* for DynaExplode() */
+    MovDelay[jx][jy] = 96;
     player->dynabombs_left--;
-    DrawGraphicThruMask(SCROLLX(JX),SCROLLY(JY),GFX_DYNABOMB);
+    DrawGraphicThruMask(SCROLLX(jx),SCROLLY(jy),GFX_DYNABOMB);
   }
 
   return(TRUE);
index 5620933558ac2ba1afae56ba9874bb1b783b88ff..b0aa6e9f9c6700bb7b229ce104ffa6e6d4311ebc 100644 (file)
@@ -25,6 +25,9 @@
 #define MF_MOVING              1
 #define MF_ACTION              2
 
+#define SCROLL_FIGURE_INIT     0
+#define SCROLL_FIGURE_GO_ON    1
+
 /* explosion position marks */
 #define EX_NORMAL              0
 #define EX_CENTER              1
@@ -49,7 +52,7 @@ void RemoveMovingField(int, int);
 void DrawDynamite(int, int);
 void CheckDynamite(int, int);
 void Explode(int, int, int, int);
-void DynaExplode(int, int, int);
+void DynaExplode(int, int);
 void Bang(int, int);
 void Blurb(int, int);
 void Impact(int, int);
@@ -74,24 +77,24 @@ void MauerWaechst(int, int);
 void MauerAbleger(int, int);
 void GameActions(int);
 void ScrollLevel(int, int);
-BOOL MoveFigureOneStep(int, int, int, int);
-BOOL MoveFigure(int, int);
 
-void ScrollFigure(int);
+BOOL MoveFigureOneStep(struct PlayerInfo *, int, int, int, int);
+BOOL MoveFigure(struct PlayerInfo *, int, int);
+void ScrollFigure(struct PlayerInfo *, int);
 
 void TestIfGoodThingHitsBadThing(int, int);
 void TestIfBadThingHitsGoodThing(int, int);
-void TestIfHeroHitsBadThing(void);
-void TestIfBadThingHitsHero(void);
+void TestIfHeroHitsBadThing(int, int);
+void TestIfBadThingHitsHero(int, int);
 void TestIfFriendHitsBadThing(int, int);
 void TestIfBadThingHitsFriend(int, int);
 void TestIfBadThingHitsOtherBadThing(int, int);
-void KillHero(void);
-void BuryHero(void);
-void RemoveHero(void);
-int DigField(int, int, int, int, int);
-BOOL SnapField(int, int);
-BOOL PlaceBomb(void);
+void KillHero(struct PlayerInfo *);
+void BuryHero(struct PlayerInfo *);
+void RemoveHero(struct PlayerInfo *);
+int DigField(struct PlayerInfo *, int, int, int, int, int);
+BOOL SnapField(struct PlayerInfo *, int, int);
+BOOL PlaceBomb(struct PlayerInfo *);
 void PlaySoundLevel(int, int, int);
 void RaiseScore(int);
 void RaiseScoreElement(int);
index c6cd0da3953dc0e1a9226aa4663ab461851ad15c..4181eb00cb58737be9d121288400b7d6c5d4d0c3 100644 (file)
@@ -80,7 +80,7 @@ void OpenAll(int argc, char *argv[])
 
 void InitLevelAndPlayerInfo()
 {
-  player = local_player = &stored_player[0];
+  local_player = &stored_player[0];
 
   if (!LoadLevelInfo())                        /* global level info */
     CloseAll();
@@ -432,17 +432,36 @@ void InitGfx()
   }
   tile_needs_clipping[] =
   {
-    { GFX_SPIELER_UP, 4 },
-    { GFX_SPIELER_DOWN, 4 },
-    { GFX_SPIELER_LEFT, 4 },
-    { GFX_SPIELER_RIGHT, 4 },
-    { GFX_SPIELER_PUSH_LEFT, 4 },
-    { GFX_SPIELER_PUSH_RIGHT, 4 },
+    { GFX_SPIELER1_UP, 4 },
+    { GFX_SPIELER1_DOWN, 4 },
+    { GFX_SPIELER1_LEFT, 4 },
+    { GFX_SPIELER1_RIGHT, 4 },
+    { GFX_SPIELER1_PUSH_LEFT, 4 },
+    { GFX_SPIELER1_PUSH_RIGHT, 4 },
+    { GFX_SPIELER2_UP, 4 },
+    { GFX_SPIELER2_DOWN, 4 },
+    { GFX_SPIELER2_LEFT, 4 },
+    { GFX_SPIELER2_RIGHT, 4 },
+    { GFX_SPIELER2_PUSH_LEFT, 4 },
+    { GFX_SPIELER2_PUSH_RIGHT, 4 },
+    { GFX_SPIELER3_UP, 4 },
+    { GFX_SPIELER3_DOWN, 4 },
+    { GFX_SPIELER3_LEFT, 4 },
+    { GFX_SPIELER3_RIGHT, 4 },
+    { GFX_SPIELER3_PUSH_LEFT, 4 },
+    { GFX_SPIELER3_PUSH_RIGHT, 4 },
+    { GFX_SPIELER4_UP, 4 },
+    { GFX_SPIELER4_DOWN, 4 },
+    { GFX_SPIELER4_LEFT, 4 },
+    { GFX_SPIELER4_RIGHT, 4 },
+    { GFX_SPIELER4_PUSH_LEFT, 4 },
+    { GFX_SPIELER4_PUSH_RIGHT, 4 },
     { GFX_GEBLUBBER, 4 },
     { GFX_DYNAMIT, 7 },
     { GFX_DYNABOMB, 4 },
     { GFX_SOKOBAN_OBJEKT, 1 },
-    { GFX_MASK_SPARKLING, 3 },
+    { GFX_FUNKELN_BLAU, 3 },
+    { GFX_FUNKELN_WEISS, 3 },
     { -1, 0 }
   };
 
@@ -504,15 +523,8 @@ void InitGfx()
       int src_x, src_y;
       Pixmap src_pixmap;
 
-      if (tile_needs_clipping[i].start == GFX_MASK_SPARKLING)
-      {
-       /* special case -- should be cleaned up sometimes... */
-       src_pixmap = clipmask[PIX_BACK];
-       src_x  = SX + GFX_PER_LINE*TILEX;
-       src_y  = SY + j*TILEY;
-      }
-      else if (graphic >= GFX_START_ROCKSSCREEN &&
-              graphic <= GFX_END_ROCKSSCREEN)
+      if (graphic >= GFX_START_ROCKSSCREEN &&
+         graphic <= GFX_END_ROCKSSCREEN)
       {
        src_pixmap = clipmask[PIX_BACK];
        graphic -= GFX_START_ROCKSSCREEN;
index 2a8af5d08dce96805db896728142e65738cdedcc..d5c5014887ff19eb1a30158e1916472531ef4102 100644 (file)
@@ -91,15 +91,15 @@ int         lev_fieldx,lev_fieldy, scroll_x,scroll_y;
 int            FX = SX, FY = SY, ScreenMovPos = 0, ScrollStepSize = TILEX/8;
 int            GameFrameDelay = GAME_FRAME_DELAY, MoveSpeed = 8;
 int            BX1 = 0, BY1 = 0, BX2 = SCR_FIELDX-1, BY2 = SCR_FIELDY-1;
-int            JX,JY, lastJX,lastJY, ZX,ZY, ExitX,ExitY;
-int            PlayerGone, LevelSolved, GameOver;
+int            ZX,ZY, ExitX,ExitY;
+int            AllPlayersGone;
 int            FrameCounter, TimeFrames, TimeLeft;
 int            MampferNr, SiebAktiv;
 
 struct LevelDirInfo    leveldir[MAX_LEVDIR_ENTRIES];
 struct LevelInfo       level;
 struct PlayerInfo      stored_player[MAX_PLAYERS+1];
-struct PlayerInfo      *local_player, *player;
+struct PlayerInfo      *local_player;
 struct HiScore         highscore[MAX_SCORE_ENTRIES];
 struct SoundInfo       Sound[NUM_SOUNDS];
 struct RecordingInfo   tape;
index ae4d28074a51e43e36144c03122e5d48c9f97aa0..d967565c231cb75efc18e3014118820bd6838713 100644 (file)
@@ -170,6 +170,8 @@ typedef int BOOL;
 #define TAPE_IS_EMPTY(x)       ((x).length == 0)
 #define TAPE_IS_STOPPED(x)     (!(x).recording && !(x).playing &&!(x).pausing)
 
+#define PLAYERINFO(x,y)                (&stored_player[StorePlayer[x][y]-EL_SPIELER1])
+
 /* Pixmaps with Xpm or X11 Bitmap files */
 #define PIX_BACK               0
 #define PIX_DOOR               1
@@ -219,11 +221,13 @@ struct PlayerInfo
   int leveldir_nr;
   int level_nr;
 
-  int JX,JY, lastJX,lastJY, ZX,ZY, ExitX,ExitY;
+  int jx,jy, last_jx,last_jy;
   int MovDir, MovPos, Pushing;
   int Frame, GfxPos;
 
-  int PlayerGone, LevelSolved, GameOver;
+  int gone, LevelSolved, GameOver;
+
+  long actual_frame_counter;
 
   int frame_reset_delay;
 
@@ -233,6 +237,8 @@ struct PlayerInfo
   long push_delay;
   int push_delay_value;
 
+  int snapped;
+
   int score;
   int gems_still_needed;
   int sokobanfields_still_needed;
@@ -359,15 +365,15 @@ extern int                lev_fieldx,lev_fieldy, scroll_x,scroll_y;
 extern int             FX,FY, ScreenMovPos, ScrollStepSize;
 extern int             GameFrameDelay, MoveSpeed;
 extern int             BX1,BY1, BX2,BY2;
-extern int             JX,JY, lastJX,lastJY, ZX,ZY, ExitX,ExitY;
-extern int             PlayerGone,LevelSolved,GameOver;
-extern int             FrameCounter,TimeFrames,TimeLeft;
+extern int             ZX,ZY, ExitX,ExitY;
+extern int             AllPlayersGone;
+extern int             FrameCounter, TimeFrames, TimeLeft;
 extern int             MampferNr, SiebAktiv;
 
 extern struct LevelDirInfo     leveldir[];
 extern struct LevelInfo                level;
 extern struct PlayerInfo       stored_player[];
-extern struct PlayerInfo       *local_player, *player;
+extern struct PlayerInfo       *local_player;
 extern struct HiScore          highscore[];
 extern struct RecordingInfo    tape;
 extern struct SoundInfo                Sound[];
@@ -778,23 +784,37 @@ extern char               *progname;
 #define GFX_FIREFLY_L          206
 #define GFX_FIREFLY_U          207
 
-/* CHANGE THIS!!!! (NO REGULAR POSITIONS...) */
-#define GFX_MASK_SPARKLING     210
-/* CHANGE THIS!!!! (NO REGULAR POSITIONS...) */
-
 #define GFX_SCHLUESSEL         GFX_SCHLUESSEL1
 #define GFX_SPIELFIGUR         GFX_SPIELER1
 
 
 /* graphics from "RocksHeroes" */
 
-#define GFX_SPIELER_DOWN       (GFX_START_ROCKSHEROES + 0*HEROES_PER_LINE + 0)
-#define GFX_SPIELER_UP         (GFX_START_ROCKSHEROES + 0*HEROES_PER_LINE + 4)
-#define GFX_SPIELER_LEFT       (GFX_START_ROCKSHEROES + 1*HEROES_PER_LINE + 0)
-#define GFX_SPIELER_RIGHT      (GFX_START_ROCKSHEROES + 1*HEROES_PER_LINE + 4)
-#define GFX_SPIELER_PUSH_RIGHT (GFX_START_ROCKSHEROES + 2*HEROES_PER_LINE + 0)
-#define GFX_SPIELER_PUSH_LEFT  (GFX_START_ROCKSHEROES + 2*HEROES_PER_LINE + 4)
-#define GFX_SONDE_START                (GFX_START_ROCKSHEROES + 7*HEROES_PER_LINE + 0)
+#define GFX_SPIELER1_DOWN      (GFX_START_ROCKSHEROES + 0*HEROES_PER_LINE + 0)
+#define GFX_SPIELER1_UP                (GFX_START_ROCKSHEROES + 0*HEROES_PER_LINE + 4)
+#define GFX_SPIELER1_LEFT      (GFX_START_ROCKSHEROES + 1*HEROES_PER_LINE + 0)
+#define GFX_SPIELER1_RIGHT     (GFX_START_ROCKSHEROES + 1*HEROES_PER_LINE + 4)
+#define GFX_SPIELER1_PUSH_RIGHT        (GFX_START_ROCKSHEROES + 2*HEROES_PER_LINE + 0)
+#define GFX_SPIELER1_PUSH_LEFT (GFX_START_ROCKSHEROES + 2*HEROES_PER_LINE + 4)
+#define GFX_SPIELER2_DOWN      (GFX_START_ROCKSHEROES + 3*HEROES_PER_LINE + 0)
+#define GFX_SPIELER2_UP                (GFX_START_ROCKSHEROES + 3*HEROES_PER_LINE + 4)
+#define GFX_SPIELER2_LEFT      (GFX_START_ROCKSHEROES + 4*HEROES_PER_LINE + 0)
+#define GFX_SPIELER2_RIGHT     (GFX_START_ROCKSHEROES + 4*HEROES_PER_LINE + 4)
+#define GFX_SPIELER2_PUSH_RIGHT        (GFX_START_ROCKSHEROES + 5*HEROES_PER_LINE + 0)
+#define GFX_SPIELER2_PUSH_LEFT (GFX_START_ROCKSHEROES + 5*HEROES_PER_LINE + 4)
+#define GFX_SPIELER3_DOWN      (GFX_START_ROCKSHEROES + 6*HEROES_PER_LINE + 0)
+#define GFX_SPIELER3_UP                (GFX_START_ROCKSHEROES + 6*HEROES_PER_LINE + 4)
+#define GFX_SPIELER3_LEFT      (GFX_START_ROCKSHEROES + 7*HEROES_PER_LINE + 0)
+#define GFX_SPIELER3_RIGHT     (GFX_START_ROCKSHEROES + 7*HEROES_PER_LINE + 4)
+#define GFX_SPIELER3_PUSH_RIGHT        (GFX_START_ROCKSHEROES + 8*HEROES_PER_LINE + 0)
+#define GFX_SPIELER3_PUSH_LEFT (GFX_START_ROCKSHEROES + 8*HEROES_PER_LINE + 4)
+#define GFX_SPIELER4_DOWN      (GFX_START_ROCKSHEROES + 9*HEROES_PER_LINE + 0)
+#define GFX_SPIELER4_UP                (GFX_START_ROCKSHEROES + 9*HEROES_PER_LINE + 4)
+#define GFX_SPIELER4_LEFT      (GFX_START_ROCKSHEROES +10*HEROES_PER_LINE + 0)
+#define GFX_SPIELER4_RIGHT     (GFX_START_ROCKSHEROES +10*HEROES_PER_LINE + 4)
+#define GFX_SPIELER4_PUSH_RIGHT        (GFX_START_ROCKSHEROES +11*HEROES_PER_LINE + 0)
+#define GFX_SPIELER4_PUSH_LEFT (GFX_START_ROCKSHEROES +11*HEROES_PER_LINE + 4)
+#define GFX_SONDE_START                (GFX_START_ROCKSHEROES + 9*HEROES_PER_LINE + 8)
 #define GFX_SCHWEIN_DOWN       (GFX_START_ROCKSHEROES + 0*HEROES_PER_LINE + 8)
 #define GFX_SCHWEIN_UP         (GFX_START_ROCKSHEROES + 0*HEROES_PER_LINE +12)
 #define GFX_SCHWEIN_LEFT       (GFX_START_ROCKSHEROES + 1*HEROES_PER_LINE + 8)
@@ -807,16 +827,18 @@ extern char               *progname;
 #define GFX_MAULWURF_UP                (GFX_START_ROCKSHEROES + 4*HEROES_PER_LINE +12)
 #define GFX_MAULWURF_LEFT      (GFX_START_ROCKSHEROES + 5*HEROES_PER_LINE + 8)
 #define GFX_MAULWURF_RIGHT     (GFX_START_ROCKSHEROES + 5*HEROES_PER_LINE +12)
-#define GFX_PINGUIN_DOWN       (GFX_START_ROCKSHEROES + 7*HEROES_PER_LINE + 8)
-#define GFX_PINGUIN_UP         (GFX_START_ROCKSHEROES + 7*HEROES_PER_LINE +12)
-#define GFX_PINGUIN_LEFT       (GFX_START_ROCKSHEROES + 8*HEROES_PER_LINE + 8)
-#define GFX_PINGUIN_RIGHT      (GFX_START_ROCKSHEROES + 8*HEROES_PER_LINE +12)
-#define GFX_BLURB_LEFT         (GFX_START_ROCKSHEROES + 9*HEROES_PER_LINE + 8)
-#define GFX_BLURB_RIGHT                (GFX_START_ROCKSHEROES + 9*HEROES_PER_LINE +12)
-#define GFX_FLAMMEN_LEFT       (GFX_START_ROCKSHEROES + 8*HEROES_PER_LINE + 0)
-#define GFX_FLAMMEN_RIGHT      (GFX_START_ROCKSHEROES + 9*HEROES_PER_LINE + 0)
-#define GFX_FLAMMEN_UP         (GFX_START_ROCKSHEROES +10*HEROES_PER_LINE + 0)
-#define GFX_FLAMMEN_DOWN       (GFX_START_ROCKSHEROES +11*HEROES_PER_LINE + 0)
+#define GFX_PINGUIN_DOWN       (GFX_START_ROCKSHEROES + 6*HEROES_PER_LINE + 8)
+#define GFX_PINGUIN_UP         (GFX_START_ROCKSHEROES + 6*HEROES_PER_LINE +12)
+#define GFX_PINGUIN_LEFT       (GFX_START_ROCKSHEROES + 7*HEROES_PER_LINE + 8)
+#define GFX_PINGUIN_RIGHT      (GFX_START_ROCKSHEROES + 7*HEROES_PER_LINE +12)
+#define GFX_BLURB_LEFT         (GFX_START_ROCKSHEROES +10*HEROES_PER_LINE + 8)
+#define GFX_BLURB_RIGHT                (GFX_START_ROCKSHEROES +10*HEROES_PER_LINE +12)
+#define GFX_FUNKELN_BLAU       (GFX_START_ROCKSHEROES +11*HEROES_PER_LINE + 8)
+#define GFX_FUNKELN_WEISS      (GFX_START_ROCKSHEROES +11*HEROES_PER_LINE +12)
+#define GFX_FLAMMEN_LEFT       (GFX_START_ROCKSHEROES +12*HEROES_PER_LINE + 8)
+#define GFX_FLAMMEN_RIGHT      (GFX_START_ROCKSHEROES +13*HEROES_PER_LINE + 8)
+#define GFX_FLAMMEN_UP         (GFX_START_ROCKSHEROES +14*HEROES_PER_LINE + 8)
+#define GFX_FLAMMEN_DOWN       (GFX_START_ROCKSHEROES +15*HEROES_PER_LINE + 8)
 
 /* graphics from "RocksFont" */
 #define GFX_CHAR_START         (GFX_START_ROCKSFONT)
index aca0be51e166e31a7375659b651a52f01708cd03..5cc2e514e2e3b82ccf3c35344b4b159fb7a2f3b1 100644 (file)
@@ -69,7 +69,7 @@ void DrawMainMenu()
   DrawGraphic(10,3,GFX_PFEIL_L);
   DrawGraphic(14,3,GFX_PFEIL_R);
 
-  DrawText(SX+54+16,SY+326,"A Game by Artsoft Development",FS_SMALL,FC_BLUE);
+  DrawText(SX+40+16,SY+326,"A Game by Artsoft Entertainment",FS_SMALL,FC_BLUE);
   DrawText(SX+40+16,SY+344,"Graphics: Deluxe Paint IV Amiga",
           FS_SMALL,FC_BLUE);
   DrawText(SX+60+16,SY+362,"Sounds: AudioMaster IV Amiga",
@@ -255,12 +255,12 @@ static int helpscreen_frame[MAX_HELPSCREEN_ELS];
 static int helpscreen_delay[MAX_HELPSCREEN_ELS];
 static int helpscreen_action[] =
 {
-  GFX_SPIELER_DOWN,4,2,
-  GFX_SPIELER_UP,4,2,
-  GFX_SPIELER_LEFT,4,2,
-  GFX_SPIELER_RIGHT,4,2,
-  GFX_SPIELER_PUSH_LEFT,4,2,
-  GFX_SPIELER_PUSH_RIGHT,4,2,                                  HA_NEXT,
+  GFX_SPIELER1_DOWN,4,2,
+  GFX_SPIELER1_UP,4,2,
+  GFX_SPIELER1_LEFT,4,2,
+  GFX_SPIELER1_RIGHT,4,2,
+  GFX_SPIELER1_PUSH_LEFT,4,2,
+  GFX_SPIELER1_PUSH_RIGHT,4,2,                                 HA_NEXT,
   GFX_ERDREICH,1,100,                                          HA_NEXT,
   GFX_LEERRAUM,1,100,                                          HA_NEXT,
   GFX_MORAST_LEER,1,100,                                       HA_NEXT,
@@ -1304,10 +1304,10 @@ void HandleGameActions(int player_action)
   if (game_status != PLAYING)
     return;
 
-  if (LevelSolved)
+  if (local_player->LevelSolved)
     GameWon();
 
-  if (PlayerGone && !TAPE_IS_STOPPED(tape))
+  if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
     TapeStop();
 
   GameActions(player_action);
@@ -1477,7 +1477,7 @@ void HandleGameButtons(int mx, int my, int button)
   switch(CheckGameButtons(mx,my,button))
   {
     case BUTTON_GAME_STOP:
-      if (GameOver)
+      if (AllPlayersGone)
       {
        CloseDoor(DOOR_CLOSE_1);
        game_status = MAINMENU;
index f742f69e7dacbfb2452662cb796cd964e4dc9f91..2ddafd70bb928f66464c0c565ffc7f20a3c03fb7 100644 (file)
@@ -330,24 +330,40 @@ void DrawTextExt(Drawable d, GC gc, int x, int y,
   }
 }
 
-void DrawPlayerField(int x, int y)
+void DrawAllPlayers()
 {
-  int lastJX = player->lastJX, lastJY = player->lastJY;
-  int sx = SCROLLX(x), sy = SCROLLY(y);
-  int sxx = 0, syy = 0;
-  int element = Feld[x][y];
-  int graphic, phase;
+  int i;
 
+  for(i=0; i<MAX_PLAYERS; i++)
+    if (stored_player[i].active)
+      DrawPlayer(&stored_player[i]);
+}
+
+void DrawPlayerField(int x, int y)
+{
   if (!IS_PLAYER(x,y))
     return;
 
-  if (PlayerGone)
+  DrawPlayer(PLAYERINFO(x,y));
+}
+
+void DrawPlayer(struct PlayerInfo *player)
+{
+  int jx = player->jx, jy = player->jy;
+  int last_jx = player->last_jx, last_jy = player->last_jy;
+  int next_jx = jx + (jx - last_jx), next_jy = jy + (jy - last_jy);
+  int sx = SCROLLX(jx), sy = SCROLLY(jy);
+  int sxx = 0, syy = 0;
+  int element = Feld[jx][jy];
+  int graphic, phase;
+
+  if (!player->active || player->gone || !IN_SCR_FIELD(sx,sy))
     return;
 
 #if DEBUG
-  if (!IN_LEV_FIELD(x,y) || !IN_SCR_FIELD(sx,sy))
+  if (!IN_LEV_FIELD(jx,jy) || !IN_SCR_FIELD(sx,sy))
   {
-    printf("DrawPlayerField(): x = %d, y = %d\n",x,y);
+    printf("DrawPlayerField(): x = %d, y = %d\n",jx,jy);
     printf("DrawPlayerField(): sx = %d, sy = %d\n",sx,sy);
     printf("DrawPlayerField(): This should never happen!\n");
     return;
@@ -362,53 +378,51 @@ void DrawPlayerField(int x, int y)
 
   /* draw things in the field the player is leaving, if needed */
 
-  if (lastJX != JX || lastJY != JY)
+  if (last_jx != jx || last_jy != jy)
   {
-    if (Store[lastJX][lastJY])
+    if (Store[last_jx][last_jy])
     {
-      DrawLevelElement(lastJX,lastJY, Store[lastJX][lastJY]);
-      DrawLevelElementThruMask(lastJX,lastJY, Feld[lastJX][lastJY]);
+      DrawLevelElement(last_jx,last_jy, Store[last_jx][last_jy]);
+      DrawLevelElementThruMask(last_jx,last_jy, Feld[last_jx][last_jy]);
     }
-    else if (Feld[lastJX][lastJY] == EL_DYNAMIT)
-      DrawDynamite(lastJX,lastJY);
+    else if (Feld[last_jx][last_jy] == EL_DYNAMIT)
+      DrawDynamite(last_jx,last_jy);
     else
-      DrawLevelField(lastJX,lastJY);
+      DrawLevelField(last_jx,last_jy);
 
     if (player->Pushing)
     {
-      int nextJX = JX + (JX - lastJX);
-      int nextJY = JY + (JY - lastJY);
-
       if (player->GfxPos)
       {
-       if (Feld[nextJX][nextJY] == EL_SOKOBAN_FELD_VOLL)
-         DrawLevelElement(nextJX,nextJY, EL_SOKOBAN_FELD_LEER);
+       if (Feld[next_jx][next_jy] == EL_SOKOBAN_FELD_VOLL)
+         DrawLevelElement(next_jx,next_jy, EL_SOKOBAN_FELD_LEER);
        else
-         DrawLevelElement(nextJX,nextJY, EL_LEERRAUM);
+         DrawLevelElement(next_jx,next_jy, EL_LEERRAUM);
       }
       else
-       DrawLevelField(nextJX,nextJY);
+       DrawLevelField(next_jx,next_jy);
     }
   }
 
   /* draw things behind the player, if needed */
 
-  if (Store[x][y])
-    DrawLevelElement(x,y, Store[x][y]);
+  if (Store[jx][jy])
+    DrawLevelElement(jx,jy, Store[jx][jy]);
   else if (element != EL_DYNAMIT && element != EL_DYNABOMB)
-    DrawLevelField(x,y);
+    DrawLevelField(jx,jy);
 
   /* draw player himself */
 
   if (player->MovDir==MV_LEFT)
-    graphic = (player->Pushing ? GFX_SPIELER_PUSH_LEFT : GFX_SPIELER_LEFT);
+    graphic = (player->Pushing ? GFX_SPIELER1_PUSH_LEFT : GFX_SPIELER1_LEFT);
   else if (player->MovDir==MV_RIGHT)
-    graphic = (player->Pushing ? GFX_SPIELER_PUSH_RIGHT : GFX_SPIELER_RIGHT);
+    graphic = (player->Pushing ? GFX_SPIELER1_PUSH_RIGHT : GFX_SPIELER1_RIGHT);
   else if (player->MovDir==MV_UP)
-    graphic = GFX_SPIELER_UP;
+    graphic = GFX_SPIELER1_UP;
   else /* MV_DOWN || MV_NO_MOVING */
-    graphic = GFX_SPIELER_DOWN;
+    graphic = GFX_SPIELER1_DOWN;
 
+  graphic += player->nr * 3*HEROES_PER_LINE;
   graphic += player->Frame;
 
   if (player->GfxPos)
@@ -426,16 +440,14 @@ void DrawPlayerField(int x, int y)
 
   if (player->Pushing && player->GfxPos)
   {
-    int nextJX = JX + (JX - lastJX);
-    int nextJY = JY + (JY - lastJY);
-    int px = SCROLLX(nextJX), py = SCROLLY(nextJY);
+    int px = SCROLLX(next_jx), py = SCROLLY(next_jy);
 
-    if (Feld[JX][JY] == EL_SOKOBAN_FELD_LEER ||
-       Feld[nextJX][nextJY] == EL_SOKOBAN_FELD_VOLL)
+    if (Feld[jx][jy] == EL_SOKOBAN_FELD_LEER ||
+       Feld[next_jx][next_jy] == EL_SOKOBAN_FELD_VOLL)
       DrawGraphicShiftedThruMask(px,py,sxx,syy, GFX_SOKOBAN_OBJEKT,NO_CUTTING);
     else
     {
-      int element = Feld[nextJX][nextJY];
+      int element = Feld[next_jx][next_jy];
       int graphic = el2gfx(element);
 
       if (element == EL_FELSBROCKEN && sxx)
@@ -460,12 +472,12 @@ void DrawPlayerField(int x, int y)
 
     if (element == EL_DYNAMIT)
     {
-      if ((phase = (96-MovDelay[x][y])/12) > 6)
+      if ((phase = (96-MovDelay[jx][jy])/12) > 6)
        phase = 6;
     }
     else
     {
-      if ((phase = ((96-MovDelay[x][y])/6) % 8) > 3)
+      if ((phase = ((96-MovDelay[jx][jy])/6) % 8) > 3)
        phase = 7-phase;
     }
 
@@ -474,17 +486,17 @@ void DrawPlayerField(int x, int y)
 
   if (direct_draw_on)
   {
-    int dest_x = SX+SCROLLX(x)*TILEX;
-    int dest_y = SY+SCROLLY(y)*TILEY;
+    int dest_x = SX + sx*TILEX;
+    int dest_y = SY + sy*TILEY;
     int x_size = TILEX;
     int y_size = TILEY;
 
     if (!ScreenMovPos)
     {
-      dest_x = SX + SCROLLX(MIN(JX,lastJX))*TILEX;
-      dest_y = SY + SCROLLY(MIN(JY,lastJY))*TILEY;
-      x_size = TILEX * (1 + ABS(JX - lastJX));
-      y_size = TILEY * (1 + ABS(JY - lastJY));
+      dest_x = SX + SCROLLX(MIN(jx,last_jx))*TILEX;
+      dest_y = SY + SCROLLY(MIN(jy,last_jy))*TILEY;
+      x_size = TILEX * (1 + ABS(jx - last_jx));
+      y_size = TILEY * (1 + ABS(jy - last_jy));
     }
 
     XCopyArea(display,drawto_field,window,gc,
index 47239c9073051f71ae5336b12958c84b2d460bf6..557598227d019621d16573a89f0a2a65673823fd 100644 (file)
@@ -63,7 +63,9 @@ void FadeToFront();
 void ClearWindow();
 void DrawText(int, int, char *, int, int);
 void DrawTextExt(Drawable, GC, int, int, char *, int, int);
+void DrawAllPlayers(void);
 void DrawPlayerField(int, int);
+void DrawPlayer(struct PlayerInfo *);
 void DrawGraphicAnimationExt(int, int, int, int, int, int, int);
 void DrawGraphicAnimation(int, int, int, int, int, int);
 void DrawGraphicAnimationThruMask(int, int, int, int, int, int);