added special handling of BD intermission levels when restarting game
[rocksndiamonds.git] / src / game_bd / bd_graphics.c
index 32af6e2a29b921c8377340ab5ccdf4196aad42df..b122219a6284575695f305040db1560830ccf96d 100644 (file)
@@ -61,6 +61,8 @@ static int cell_size = 0;
 
 // graphic info for game objects/frames and players/actions/frames
 struct GraphicInfo_BD graphic_info_bd_object[O_MAX_ALL][8];
+// graphic info for game graphics template for level-specific colors
+struct GraphicInfo_BD graphic_info_bd_color_template;
 
 static inline int c64_png_colors(int r, int g, int b, int a)
 {
@@ -453,15 +455,17 @@ void gd_prepare_tile_bitmap(GdCave *cave, Bitmap *bitmap, int scale_down_factor)
 {
   static SDL_Surface *tile_surface_c64 = NULL;
   static Bitmap *gd_tile_bitmap_original = NULL;
+  static int scale_down_factor_last = -1;
 
   // check if tile bitmap has changed (different artwork or tile size selected)
-  if (bitmap != gd_tile_bitmap_original)
+  if (bitmap != gd_tile_bitmap_original || scale_down_factor != scale_down_factor_last)
   {
     // check if tile bitmap has limited C64 style colors
     tile_surface_c64 = get_tile_surface_c64(bitmap->surface, scale_down_factor);
 
-    // store original tile bitmap from current artwork set
+    // store original tile bitmap from current artwork set and scaling factor
     gd_tile_bitmap_original = bitmap;
+    scale_down_factor_last = scale_down_factor;
 
     // store reference tile bitmap from current artwork set (may be changed later)
     gd_tile_bitmap_reference = bitmap;
@@ -609,8 +613,8 @@ static void gd_drawcave_tile(Bitmap *dest, GdGame *game, int x, int y, boolean d
     // redraw previous game element on the cave field the new element is moving to
     int tile_last = game->last_element_buffer[y][x];
 
-    // only redraw previous game element if it is not collectible (like dirt etc.)
-    if (is_collectible(tile_last))
+    // only redraw previous game element if it is diggable (like dirt etc.)
+    if (!is_diggable(tile_last))
       tile_last = O_SPACE;
 
     struct GraphicInfo_BD *g_old = &graphic_info_bd_object[tile_last][frame];
@@ -646,7 +650,9 @@ static void gd_drawcave_tile(Bitmap *dest, GdGame *game, int x, int y, boolean d
     else
     {
       // if old tile also moving (like pushing player), do not redraw tile background
-      game->last_element_buffer[old_y][old_x] |= SKIPPED;
+      // (but redraw if tile and old tile are moving/falling into different directions)
+      if (game->dir_buffer[old_y][old_x] == game->dir_buffer[y][x])
+       game->last_element_buffer[old_y][old_x] |= SKIPPED;
     }
   }