1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-26 14:38:30 +02:00

Fix the 2nd to 4th tiles of moving plats rendering offset from 1st tile

This commit fixes a bug where the second, third, and fourth tiles of
moving platforms would render offset from the first tile if the moving
platform hit the top or left edge of the screen.

This is due to the fact that SDL_BlitSurface() will end up changing the
coordinates of the rectangle we pass to it to be 0 if they're negative,
but only after it's already been drawn. Previously, we kept re-using the
same rectangle each time we drew each segment of the moving platform,
but since it only changes the draw rectangle after it's already been
drawn, the first tile shows up fine, but not the rest of the tiles,
hence resulting in an offset.

To fix this, we do the same thing as we did for drawing the "really big
sprite" (size-type 9): just reset the rectangle we use every time we
draw a segment of the moving platform.
This commit is contained in:
Misa 2020-04-25 14:57:05 -07:00 committed by Ethan Lee
parent da612de1f4
commit a60cdb3ab7

View File

@ -1532,9 +1532,6 @@ void Graphics::drawentities()
// Special: Moving platform, 4 tiles or 8 tiles
tpoint.x = obj.entities[i].xp;
tpoint.y = obj.entities[i].yp;
drawRect = tiles_rect;
drawRect.x += tpoint.x;
drawRect.y += tpoint.y;
int thiswidth = 4;
if (obj.entities[i].size == 8)
{
@ -1542,8 +1539,11 @@ void Graphics::drawentities()
}
for (int ii = 0; ii < thiswidth; ii++)
{
drawRect = tiles_rect;
drawRect.x += tpoint.x;
drawRect.y += tpoint.y;
drawRect.x += 8 * ii;
BlitSurfaceStandard((*tilesvec)[obj.entities[i].drawframe],NULL, backBuffer, &drawRect);
drawRect.x += 8;
}
}
else if (obj.entities[i].size == 3) // Big chunky pixels!