mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-08 18:09:45 +01:00
Make Graphics::drawentities() use a case-switch instead of an else-if
Makes it easier to read and doesn't require copy-pasting or re-typing 'obj.entities[i].size =='.
This commit is contained in:
parent
02dc1084e7
commit
b5e813dbbb
1 changed files with 31 additions and 37 deletions
|
@ -1427,8 +1427,9 @@ void Graphics::drawentities()
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.entities[i].size == 0)
|
switch (obj.entities[i].size)
|
||||||
{
|
{
|
||||||
|
case 0:
|
||||||
// Sprites
|
// Sprites
|
||||||
tpoint.x = obj.entities[i].xp;
|
tpoint.x = obj.entities[i].xp;
|
||||||
tpoint.y = obj.entities[i].yp;
|
tpoint.y = obj.entities[i].yp;
|
||||||
|
@ -1477,9 +1478,8 @@ void Graphics::drawentities()
|
||||||
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe],NULL, backBuffer, &drawRect, ct);
|
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe],NULL, backBuffer, &drawRect, ct);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if (obj.entities[i].size == 1)
|
case 1:
|
||||||
{
|
|
||||||
// Tiles
|
// Tiles
|
||||||
tpoint.x = obj.entities[i].xp;
|
tpoint.x = obj.entities[i].xp;
|
||||||
tpoint.y = obj.entities[i].yp;
|
tpoint.y = obj.entities[i].yp;
|
||||||
|
@ -1487,8 +1487,9 @@ void Graphics::drawentities()
|
||||||
drawRect.x += tpoint.x;
|
drawRect.x += tpoint.x;
|
||||||
drawRect.y += tpoint.y;
|
drawRect.y += tpoint.y;
|
||||||
BlitSurfaceStandard(tiles[obj.entities[i].drawframe],NULL, backBuffer, &drawRect);
|
BlitSurfaceStandard(tiles[obj.entities[i].drawframe],NULL, backBuffer, &drawRect);
|
||||||
}
|
break;
|
||||||
else if (obj.entities[i].size == 2 || obj.entities[i].size == 8)
|
case 2:
|
||||||
|
case 8:
|
||||||
{
|
{
|
||||||
// Special: Moving platform, 4 tiles or 8 tiles
|
// Special: Moving platform, 4 tiles or 8 tiles
|
||||||
tpoint.x = obj.entities[i].xp;
|
tpoint.x = obj.entities[i].xp;
|
||||||
|
@ -1506,9 +1507,9 @@ void Graphics::drawentities()
|
||||||
drawRect.x += 8 * ii;
|
drawRect.x += 8 * ii;
|
||||||
BlitSurfaceStandard((*tilesvec)[obj.entities[i].drawframe],NULL, backBuffer, &drawRect);
|
BlitSurfaceStandard((*tilesvec)[obj.entities[i].drawframe],NULL, backBuffer, &drawRect);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (obj.entities[i].size == 3) // Big chunky pixels!
|
case 3: // Big chunky pixels!
|
||||||
{
|
|
||||||
prect.x = obj.entities[i].xp;
|
prect.x = obj.entities[i].xp;
|
||||||
prect.y = obj.entities[i].yp;
|
prect.y = obj.entities[i].yp;
|
||||||
//A seperate index of colours, for simplicity
|
//A seperate index of colours, for simplicity
|
||||||
|
@ -1520,37 +1521,31 @@ void Graphics::drawentities()
|
||||||
{
|
{
|
||||||
FillRect(backBuffer,prect, int(160- help.glow/2 - (fRandom()*20)), 200- help.glow/2, 220 - help.glow);
|
FillRect(backBuffer,prect, int(160- help.glow/2 - (fRandom()*20)), 200- help.glow/2, 220 - help.glow);
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if (obj.entities[i].size == 4) // Small pickups
|
case 4: // Small pickups
|
||||||
{
|
|
||||||
drawhuetile(obj.entities[i].xp, obj.entities[i].yp, obj.entities[i].tile, obj.entities[i].colour);
|
drawhuetile(obj.entities[i].xp, obj.entities[i].yp, obj.entities[i].tile, obj.entities[i].colour);
|
||||||
}
|
break;
|
||||||
else if (obj.entities[i].size == 5) //Horizontal Line
|
case 5: //Horizontal Line
|
||||||
{
|
|
||||||
line_rect.x = obj.entities[i].xp;
|
line_rect.x = obj.entities[i].xp;
|
||||||
line_rect.y = obj.entities[i].yp;
|
line_rect.y = obj.entities[i].yp;
|
||||||
line_rect.w = obj.entities[i].w;
|
line_rect.w = obj.entities[i].w;
|
||||||
line_rect.h = 1;
|
line_rect.h = 1;
|
||||||
drawgravityline(i);
|
drawgravityline(i);
|
||||||
}
|
break;
|
||||||
else if (obj.entities[i].size == 6) //Vertical Line
|
case 6: //Vertical Line
|
||||||
{
|
|
||||||
line_rect.x = obj.entities[i].xp;
|
line_rect.x = obj.entities[i].xp;
|
||||||
line_rect.y = obj.entities[i].yp;
|
line_rect.y = obj.entities[i].yp;
|
||||||
line_rect.w = 1;
|
line_rect.w = 1;
|
||||||
line_rect.h = obj.entities[i].h;
|
line_rect.h = obj.entities[i].h;
|
||||||
drawgravityline(i);
|
drawgravityline(i);
|
||||||
}
|
break;
|
||||||
else if (obj.entities[i].size == 7) //Teleporter
|
case 7: //Teleporter
|
||||||
{
|
|
||||||
drawtele(obj.entities[i].xp, obj.entities[i].yp, obj.entities[i].drawframe, obj.entities[i].colour);
|
drawtele(obj.entities[i].xp, obj.entities[i].yp, obj.entities[i].drawframe, obj.entities[i].colour);
|
||||||
}
|
break;
|
||||||
else if (obj.entities[i].size == 8) // Special: Moving platform, 8 tiles
|
//case 8: // Special: Moving platform, 8 tiles
|
||||||
{
|
|
||||||
// Note: This code is in the 4-tile code
|
// Note: This code is in the 4-tile code
|
||||||
}
|
break;
|
||||||
else if (obj.entities[i].size == 9) // Really Big Sprite! (2x2)
|
case 9: // Really Big Sprite! (2x2)
|
||||||
{
|
|
||||||
setcol(obj.entities[i].colour);
|
setcol(obj.entities[i].colour);
|
||||||
|
|
||||||
tpoint.x = obj.entities[i].xp;
|
tpoint.x = obj.entities[i].xp;
|
||||||
|
@ -1584,9 +1579,8 @@ void Graphics::drawentities()
|
||||||
drawRect.x += tpoint.x;
|
drawRect.x += tpoint.x;
|
||||||
drawRect.y += tpoint.y;
|
drawRect.y += tpoint.y;
|
||||||
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe + 13],NULL, backBuffer, &drawRect, ct);
|
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe + 13],NULL, backBuffer, &drawRect, ct);
|
||||||
}
|
break;
|
||||||
else if (obj.entities[i].size == 10) // 2x1 Sprite
|
case 10: // 2x1 Sprite
|
||||||
{
|
|
||||||
setcol(obj.entities[i].colour);
|
setcol(obj.entities[i].colour);
|
||||||
|
|
||||||
tpoint.x = obj.entities[i].xp;
|
tpoint.x = obj.entities[i].xp;
|
||||||
|
@ -1604,14 +1598,12 @@ void Graphics::drawentities()
|
||||||
drawRect.x += tpoint.x;
|
drawRect.x += tpoint.x;
|
||||||
drawRect.y += tpoint.y;
|
drawRect.y += tpoint.y;
|
||||||
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe+1],NULL, backBuffer, &drawRect, ct);
|
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe+1],NULL, backBuffer, &drawRect, ct);
|
||||||
}
|
break;
|
||||||
else if (obj.entities[i].size == 11) //The fucking elephant
|
case 11: //The fucking elephant
|
||||||
{
|
|
||||||
setcol(obj.entities[i].colour);
|
setcol(obj.entities[i].colour);
|
||||||
drawimagecol(3, obj.entities[i].xp, obj.entities[i].yp);
|
drawimagecol(3, obj.entities[i].xp, obj.entities[i].yp);
|
||||||
}
|
break;
|
||||||
else if (obj.entities[i].size == 12) // Regular sprites that don't wrap
|
case 12: // Regular sprites that don't wrap
|
||||||
{
|
|
||||||
tpoint.x = obj.entities[i].xp;
|
tpoint.x = obj.entities[i].xp;
|
||||||
tpoint.y = obj.entities[i].yp;
|
tpoint.y = obj.entities[i].yp;
|
||||||
setcol(obj.entities[i].colour);
|
setcol(obj.entities[i].colour);
|
||||||
|
@ -1665,8 +1657,8 @@ void Graphics::drawentities()
|
||||||
drawRect.y += tpoint.y;
|
drawRect.y += tpoint.y;
|
||||||
BlitSurfaceColoured(tiles[1166],NULL, backBuffer, &drawRect, ct);
|
BlitSurfaceColoured(tiles[1166],NULL, backBuffer, &drawRect, ct);
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
else if (obj.entities[i].size == 13)
|
case 13:
|
||||||
{
|
{
|
||||||
//Special for epilogue: huge hero!
|
//Special for epilogue: huge hero!
|
||||||
|
|
||||||
|
@ -1679,6 +1671,8 @@ void Graphics::drawentities()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue