1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 01:59:43 +01:00

De-duplicate size-type 2/8 drawing by putting them together

They're literally the exact same thing, except one is 4 and the other
has an 8. No need to have all that copy-pasted code.

Actually, the only other difference was that size-type 8 set the
drawRect to sprites_rect instead of tiles_rect for some reason? Even
though it doesn't matter, anyway, because SDL_BlitSurface() only cares
about the X and Y you pass it, not the width and height, which is the
only difference between tiles_rect and sprites_rect.

To make sure that people wouldn't wonder where size-type 8 went if they
saw a blank space between size-type 7 and size-type 9, I kept the
size-type 8 conditional, but inside it is just a comment telling you to
go to size-type 2.
This commit is contained in:
Misa 2020-04-25 14:49:05 -07:00 committed by Ethan Lee
parent 2f180bb6df
commit da612de1f4

View file

@ -1527,15 +1527,20 @@ void Graphics::drawentities()
drawRect.y += tpoint.y;
BlitSurfaceStandard(tiles[obj.entities[i].drawframe],NULL, backBuffer, &drawRect);
}
else if (obj.entities[i].size == 2)
else if (obj.entities[i].size == 2 || obj.entities[i].size == 8)
{
// Special: Moving platform, 4 tiles
// 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;
for (int ii = 0; ii < 4; ii++)
int thiswidth = 4;
if (obj.entities[i].size == 8)
{
thiswidth = 8;
}
for (int ii = 0; ii < thiswidth; ii++)
{
BlitSurfaceStandard((*tilesvec)[obj.entities[i].drawframe],NULL, backBuffer, &drawRect);
drawRect.x += 8;
@ -1581,17 +1586,7 @@ void Graphics::drawentities()
}
else if (obj.entities[i].size == 8) // Special: Moving platform, 8 tiles
{
tpoint.x = obj.entities[i].xp;
tpoint.y = obj.entities[i].yp;
drawRect = sprites_rect;
drawRect.x += tpoint.x;
drawRect.y += tpoint.y;
for (int ii = 0; ii < 8; ii++)
{
BlitSurfaceStandard((*tilesvec)[obj.entities[i].drawframe],NULL, backBuffer, &drawRect);
drawRect.x += 8;
}
// Note: This code is in the 4-tile code
}
else if (obj.entities[i].size == 9) // Really Big Sprite! (2x2)
{