dougmencken / HeadOverHeels

The free and open source remake of the game “Head over Heels”
GNU General Public License v3.0
33 stars 10 forks source link

floor drawing leaves garbage #29

Closed attuska closed 6 years ago

attuska commented 6 years ago

ground

dougmencken commented 6 years ago

I bet that’s after

--- a/src/Mediator.cpp
+++ b/src/Mediator.cpp
@@ -291,7 +291,6 @@ void Mediator::reshadeWithGridItem( GridItem* item )
         // shade floor in this column, if any
         if ( room->floor[ column ] != nilPointer )
         {
-                room->floor[ column ]->binShadyImage();
                 room->floor[ column ]->setWantShadow( true );
         }
 }
@@ -328,7 +327,6 @@ void Mediator::reshadeWithFreeItem( FreeItem* item )
                         // shade floor in this column, if any
                         if ( room->floor[ column ] != nilPointer )
                         {
-                                room->floor[ column ]->binShadyImage();
                                 room->floor[ column ]->setWantShadow( true );
                         }
                 }
dougmencken commented 6 years ago

meet freshShadyImage

+void FloorTile::freshShadyImage ()
+{
+        if ( shadyImage != nilPointer )
+        {
+                allegro::destroyBitmap( shadyImage );
+
+                BITMAP* shady = create_bitmap_ex( 32, rawImage->w, rawImage->h );
+                clear_to_color( shady, Color::colorOfTransparency()->toAllegroColor() );
+                blit( rawImage, shady, 0, 0, 0, 0, rawImage->w, rawImage->h );
+                shadyImage = shady;
+        }
+}
attuska commented 6 years ago

I bet that’s after

It's been already applied in https://github.com/dougmencken/HeadOverHeels/commit/6e5e5e2c30afa8c78d0bc1bc1cc96e3e145ad3c0

dougmencken commented 6 years ago

I replaced binShadyImage with freshShadyImage which doesn’t just bin it, but makes shadyImage the exact copy of raw non~shaded image of tile

@@ -291,7 +291,7 @@ void Mediator::reshadeWithGridItem( GridItem* item )
         // shade floor in this column, if any
         if ( room->floor[ column ] != nilPointer )
         {
-                room->floor[ column ]->binShadyImage();
+                room->floor[ column ]->freshShadyImage();
                 room->floor[ column ]->setWantShadow( true );
         }
 }
@@ -328,7 +328,7 @@ void Mediator::reshadeWithFreeItem( FreeItem* item )
                         // shade floor in this column, if any
                         if ( room->floor[ column ] != nilPointer )
                         {
-                                room->floor[ column ]->binShadyImage();
+                                room->floor[ column ]->freshShadyImage ();
                                 room->floor[ column ]->setWantShadow( true );
                         }
                 }
attuska commented 6 years ago

It's good, you can close issue.