replaced function to draw graphic animation (MM engine)
[rocksndiamonds.git] / src / game_mm / mm_game.c
index c1e1452af0f7f78afadca343a116888721609e03..0cb2e094f9ebe6c7f6e727af5e70d03ead65bf11 100644 (file)
@@ -349,6 +349,10 @@ void InitGameEngine_MM()
 #endif
 
   DrawLevel_MM();
+}
+
+void InitGameEngine_MM_AfterFadingIn()
+{
   InitCycleElements();
   InitLaser();
 
@@ -503,36 +507,34 @@ int ScanPixel()
 
     for (i=0; i<4; i++)
     {
+      int px = LX + (i % 2) * 2;
+      int py = LY + (i / 2) * 2;
+      int dx = px % TILEX;
+      int dy = py % TILEY;
+      int lx = (px + TILEX) / TILEX - 1;  /* ...+TILEX...-1 to get correct */
+      int ly = (py + TILEY) / TILEY - 1;  /* negative values!              */
       Pixel pixel;
-      int px, py, lx, ly;
-
-      px = SX + LX + (i % 2) * 2;
-      py = SY + LY + (i / 2) * 2;
-      lx = (px - SX + TILEX) / TILEX - 1;  /* ...+TILEX...-1 to get correct */
-      ly = (py - SY + TILEY) / TILEY - 1;  /* negative values!              */
 
       if (IN_LEV_FIELD(lx, ly))
       {
        int element = Feld[lx][ly];
 
        if (element == EL_EMPTY || element == EL_EXPLODING_TRANSP)
+       {
          pixel = 0;
+       }
        else if (IS_WALL(element) || IS_WALL_CHANGING(element))
        {
-         int pos =
-           ((py - SY - ly * TILEY) / MINI_TILEX) * 2 +
-           (px - SX - lx * TILEX) / MINI_TILEY;
+         int pos = dy / MINI_TILEY * 2 + dx / MINI_TILEX;
 
          pixel = ((element & (1 << pos)) ? 1 : 0);
        }
        else
        {
          int graphic_mask = getMaskFromElement(element);
-         int mask_x, mask_y;
-         int dx = px - lx * TILEX;
-         int dy = py - ly * TILEY;
          Bitmap *bitmap;
          int src_x, src_y;
+         int mask_x, mask_y;
 
          getGraphicSource(graphic_mask, 0, &bitmap, &src_x, &src_y);
 
@@ -544,11 +546,8 @@ int ScanPixel()
       }
       else
       {
-       if (px < REAL_SX || px >= REAL_SX + FULL_SXSIZE ||
-           py < REAL_SY || py >= REAL_SY + FULL_SYSIZE)
-         pixel = 1;
-       else
-         pixel = 0;
+       pixel = (SX + px < REAL_SX || SX + px >= REAL_SX + FULL_SXSIZE ||
+                SY + py < REAL_SY || SY + py >= REAL_SY + FULL_SYSIZE);
       }
 
       if ((Sign[laser.current_angle] & (1 << i)) && pixel)
@@ -1192,6 +1191,9 @@ boolean HitElement(int element, int hit_mask)
 
     if (element == EL_KETTLE || element == EL_CELL)
     {
+      if (game_mm.kettles_still_needed > 0)
+       game_mm.kettles_still_needed--;
+
       RaiseScore_MM(10);
 
       if (game_mm.kettles_still_needed == 0)
@@ -2164,7 +2166,7 @@ static void Explode_MM(int x, int y, int phase, int mode)
        graphic_phase += 4;
       else
       {
-       graphic = GFX_EMPTY;
+       graphic = IMG_EMPTY;
        graphic_phase = 0;
       }
     }
@@ -3313,7 +3315,7 @@ static void GameActions_MM_Ext(byte action[MAX_PLAYERS], boolean warp_mode)
     Feld[ELX][ELY] = 0;
     Feld[x][y] = element;
 
-    DrawGraphic_MM(ELX, ELY, -1);
+    DrawGraphic_MM(ELX, ELY, IMG_EMPTY);
     DrawField_MM(x, y);
 
     if (element == EL_BLOCK_STONE && Box[ELX][ELY])
@@ -3369,7 +3371,7 @@ void MovePacMen()
 {
   static int p = -1;
   int mx, my, ox, oy, nx, ny;
-  int g, element;
+  int element;
   int l;
 
   if (++p >= game_mm.num_pacman)
@@ -3416,30 +3418,26 @@ void MovePacMen()
 
     game_mm.pacman[p].x = nx;
     game_mm.pacman[p].y = ny;
-    g = Feld[nx][ny] - EL_PACMAN_RIGHT;
+
     DrawGraphic_MM(ox, oy, IMG_EMPTY);
 
     if (element != EL_EMPTY)
     {
+      int graphic = el2gfx(Feld[nx][ny]);
+      Bitmap *bitmap;
+      int src_x, src_y;
       int i;
 
+      getGraphicSource(graphic, 0, &bitmap, &src_x, &src_y);
+
       CT = Counter();
       ox = SX + ox * TILEX;
       oy = SY + oy * TILEY;
 
       for(i=1; i<33; i+=2)
-      {
-#if 1
-       // !!! temporary fix to compile -- change to game graphics !!!
-       BlitBitmap(drawto, window,
-                  SX + g * TILEX, SY + 4 * TILEY, TILEX, TILEY,
-                  ox + i * mx, oy + i * my);
-#else
-       BlitBitmap(pix[PIX_BACK], window,
-                  SX + g * TILEX, SY + 4 * TILEY, TILEX, TILEY,
+       BlitBitmap(bitmap, window,
+                  src_x, src_y, TILEX, TILEY,
                   ox + i * mx, oy + i * my);
-#endif
-      }
       Ct = Ct + Counter() - CT;
     }
     DrawField_MM(nx, ny);