fixed using wall tiles as gray ball content elements in MM engine
authorHolger Schemel <info@artsoft.org>
Wed, 22 Feb 2023 17:51:19 +0000 (18:51 +0100)
committerHolger Schemel <info@artsoft.org>
Wed, 22 Feb 2023 17:51:19 +0000 (18:51 +0100)
src/game_mm/mm_game.c
src/game_mm/mm_main.h
src/game_mm/mm_tools.c
src/game_mm/mm_tools.h

index 2805fb77d3af6f33e4bebc4ce3967b61de5bf956..4ad6ea61a0f85bc393e5a5647391c61058a38d9d 100644 (file)
@@ -2463,7 +2463,20 @@ static void OpenSurpriseBall(int x, int y)
   int delay = 2;
 
   if (!MovDelay[x][y])         // next animation frame
+  {
+    if (IS_WALL(Store[x][y]))
+    {
+      DrawWalls_MM(x, y, Store[x][y]);
+
+      // copy wall tile to spare bitmap for "melting" animation
+      BlitBitmap(drawto, bitmap_db_field, cSX + x * TILEX, cSY + y * TILEY,
+                TILEX, TILEY, x * TILEX, y * TILEY);
+
+      DrawElement_MM(x, y, EL_BALL_GRAY);
+    }
+
     MovDelay[x][y] = 50 * delay;
+  }
 
   if (MovDelay[x][y])          // wait some time before next frame
   {
@@ -2472,11 +2485,22 @@ static void OpenSurpriseBall(int x, int y)
     if (!(MovDelay[x][y] % delay) && IN_SCR_FIELD(x, y))
     {
       Bitmap *bitmap;
-      int graphic = el2gfx(Store[x][y]);
       int gx, gy;
       int dx = RND(26), dy = RND(26);
 
-      getGraphicSource(graphic, 0, &bitmap, &gx, &gy);
+      if (IS_WALL(Store[x][y]))
+      {
+       // copy wall tile from spare bitmap for "melting" animation
+       bitmap = bitmap_db_field;
+       gx = x * TILEX;
+       gy = y * TILEY;
+      }
+      else
+      {
+       int graphic = el2gfx(Store[x][y]);
+
+       getGraphicSource(graphic, 0, &bitmap, &gx, &gy);
+      }
 
       BlitBitmap(bitmap, drawto, gx + dx, gy + dy, 6, 6,
                 cSX + x * TILEX + dx, cSY + y * TILEY + dy);
@@ -2488,6 +2512,8 @@ static void OpenSurpriseBall(int x, int y)
 
     if (!MovDelay[x][y])
     {
+      int i;
+
       Tile[x][y] = Store[x][y];
       Store[x][y] = Store2[x][y] = 0;
       MovDir[x][y] = MovPos[x][y] = MovDelay[x][y] = 0;
@@ -2495,6 +2521,15 @@ static void OpenSurpriseBall(int x, int y)
       InitField(x, y, FALSE);
       DrawField_MM(x, y);
 
+      for (i = (laser.num_damages > 0 ? laser.num_damages - 1 : 0); i >= 0; i--)
+       if (laser.damage[i].is_mirror)
+         break;
+
+      if (i > 0)
+       DrawLaser(laser.damage[i].edge - 1, DL_LASER_DISABLED);
+      else
+       DrawLaser(0, DL_LASER_DISABLED);
+
       ScanLaser();
     }
   }
@@ -3499,10 +3534,19 @@ static void GameActions_MM_Ext(void)
       game_mm.ball_choice_pos++;
 
       int new_element = native_mm_level.ball_content[element_pos];
+      int new_element_unmapped = unmap_element(new_element);
 
-      // randomly rotate newly created game element, if needed
-      if (native_mm_level.rotate_ball_content)
+      if (IS_WALL(new_element_unmapped))
+      {
+       // always use completely filled wall element
+       new_element = new_element_unmapped | 0x000f;
+      }
+      else if (native_mm_level.rotate_ball_content &&
+              get_num_elements(new_element) > 1)
+      {
+       // randomly rotate newly created game element
        new_element = get_rotated_element(new_element, RND(16));
+      }
 
       Store[ELX][ELY] = new_element;
       Store2[ELX][ELY] = TRUE;
index dafaa5d60d043a20df3846b876f41f14bfa087f4..f8b775fc872074beb300d3b4689033166409da34 100644 (file)
 
 
 extern DrawBuffer      *drawto_field;
+extern DrawBuffer      *bitmap_db_field;
 
 extern int             game_status;
 extern boolean         level_editor_test_game;
index d8dbe8becaa5270253801ca4a406f0255f8d1aa3..4e9254a7c7a29383abed7a33a993c21d0590208f 100644 (file)
@@ -1293,6 +1293,21 @@ static int map_element(int element)
   }
 }
 
+int unmap_element(int element)
+{
+  switch (element)
+  {
+    case EL_STEEL_WALL:                return EL_WALL_STEEL;
+    case EL_WOODEN_WALL:       return EL_WALL_WOOD;
+    case EL_ICE_WALL:          return EL_WALL_ICE;
+    case EL_AMOEBA_WALL:       return EL_WALL_AMOEBA;
+    case EL_DF_STEEL_WALL:     return EL_DF_WALL_STEEL;
+    case EL_DF_WOODEN_WALL:    return EL_DF_WALL_WOOD;
+
+    default:                   return element;
+  }
+}
+
 int el2gfx(int element)
 {
   return el2img_mm(map_element(element));
index 58b2beb05dafd0e6ea3c5f9da6b4555d15282ba3..8857d7ba3ec861eefbf8d34ef5a450351ac56366 100644 (file)
@@ -106,6 +106,8 @@ int get_element_phase(int);
 int get_num_elements(int);
 int get_rotated_element(int, int);
 
+int unmap_element(int);
+
 int el2gfx(int);
 int el_act2gfx(int, int);