mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-23 01:59:43 +01:00
Standardize on using reference to tilesvec/spritesvec instead of pointer
This cleans up the code readability a bit, as it's nicer to use reference syntax when indexing an array instead of that ugly pointer syntax.
This commit is contained in:
parent
5eab074e4d
commit
688b23b85d
1 changed files with 22 additions and 38 deletions
|
@ -1600,25 +1600,9 @@ void Graphics::drawentities()
|
||||||
bool custom_gray = false;
|
bool custom_gray = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::vector<SDL_Surface*> *tilesvec;
|
std::vector<SDL_Surface*>& tilesvec = (map.custommode && !map.finalmode) ? entcolours : tiles;
|
||||||
if (map.custommode && !map.finalmode)
|
|
||||||
{
|
|
||||||
tilesvec = &entcolours;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tilesvec = &tiles;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<SDL_Surface*> *spritesvec;
|
std::vector<SDL_Surface*>& spritesvec = flipmode ? flipsprites : sprites;
|
||||||
if (flipmode)
|
|
||||||
{
|
|
||||||
spritesvec = &flipsprites;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
spritesvec = &sprites;
|
|
||||||
}
|
|
||||||
|
|
||||||
int yoff;
|
int yoff;
|
||||||
if (map.towermode)
|
if (map.towermode)
|
||||||
|
@ -1645,7 +1629,7 @@ void Graphics::drawentities()
|
||||||
case 0:
|
case 0:
|
||||||
{
|
{
|
||||||
// Sprites
|
// Sprites
|
||||||
if (!INBOUNDS_VEC(obj.entities[i].drawframe, (*spritesvec)))
|
if (!INBOUNDS_VEC(obj.entities[i].drawframe, spritesvec))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1656,7 +1640,7 @@ void Graphics::drawentities()
|
||||||
drawRect = sprites_rect;
|
drawRect = sprites_rect;
|
||||||
drawRect.x += tpoint.x;
|
drawRect.x += tpoint.x;
|
||||||
drawRect.y += tpoint.y;
|
drawRect.y += tpoint.y;
|
||||||
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe], NULL, backBuffer, &drawRect, ct);
|
BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe], NULL, backBuffer, &drawRect, ct);
|
||||||
|
|
||||||
//screenwrapping!
|
//screenwrapping!
|
||||||
point wrappedPoint;
|
point wrappedPoint;
|
||||||
|
@ -1693,21 +1677,21 @@ void Graphics::drawentities()
|
||||||
drawRect = sprites_rect;
|
drawRect = sprites_rect;
|
||||||
drawRect.x += wrappedPoint.x;
|
drawRect.x += wrappedPoint.x;
|
||||||
drawRect.y += tpoint.y;
|
drawRect.y += tpoint.y;
|
||||||
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe], NULL, backBuffer, &drawRect, ct);
|
BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe], NULL, backBuffer, &drawRect, ct);
|
||||||
}
|
}
|
||||||
if (wrapY && map.warpy)
|
if (wrapY && map.warpy)
|
||||||
{
|
{
|
||||||
drawRect = sprites_rect;
|
drawRect = sprites_rect;
|
||||||
drawRect.x += tpoint.x;
|
drawRect.x += tpoint.x;
|
||||||
drawRect.y += wrappedPoint.y;
|
drawRect.y += wrappedPoint.y;
|
||||||
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe], NULL, backBuffer, &drawRect, ct);
|
BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe], NULL, backBuffer, &drawRect, ct);
|
||||||
}
|
}
|
||||||
if (wrapX && wrapY && map.warpx && map.warpy)
|
if (wrapX && wrapY && map.warpx && map.warpy)
|
||||||
{
|
{
|
||||||
drawRect = sprites_rect;
|
drawRect = sprites_rect;
|
||||||
drawRect.x += wrappedPoint.x;
|
drawRect.x += wrappedPoint.x;
|
||||||
drawRect.y += wrappedPoint.y;
|
drawRect.y += wrappedPoint.y;
|
||||||
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe], NULL, backBuffer, &drawRect, ct);
|
BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe], NULL, backBuffer, &drawRect, ct);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1728,7 +1712,7 @@ void Graphics::drawentities()
|
||||||
case 8:
|
case 8:
|
||||||
{
|
{
|
||||||
// Special: Moving platform, 4 tiles or 8 tiles
|
// Special: Moving platform, 4 tiles or 8 tiles
|
||||||
if (!INBOUNDS_VEC(obj.entities[i].drawframe, (*tilesvec)))
|
if (!INBOUNDS_VEC(obj.entities[i].drawframe, tilesvec))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1749,11 +1733,11 @@ void Graphics::drawentities()
|
||||||
{
|
{
|
||||||
colourTransform temp_ct;
|
colourTransform temp_ct;
|
||||||
temp_ct.colour = 0xFFFFFFFF;
|
temp_ct.colour = 0xFFFFFFFF;
|
||||||
BlitSurfaceTinted((*tilesvec)[obj.entities[i].drawframe],NULL, backBuffer, &drawRect, temp_ct);
|
BlitSurfaceTinted(tilesvec[obj.entities[i].drawframe],NULL, backBuffer, &drawRect, temp_ct);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BlitSurfaceStandard((*tilesvec)[obj.entities[i].drawframe],NULL, backBuffer, &drawRect);
|
BlitSurfaceStandard(tilesvec[obj.entities[i].drawframe],NULL, backBuffer, &drawRect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1795,7 +1779,7 @@ void Graphics::drawentities()
|
||||||
// Note: This code is in the 4-tile code
|
// Note: This code is in the 4-tile code
|
||||||
break;
|
break;
|
||||||
case 9: // Really Big Sprite! (2x2)
|
case 9: // Really Big Sprite! (2x2)
|
||||||
if (!INBOUNDS_VEC(obj.entities[i].drawframe, (*spritesvec)))
|
if (!INBOUNDS_VEC(obj.entities[i].drawframe, spritesvec))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1807,7 +1791,7 @@ void Graphics::drawentities()
|
||||||
drawRect = sprites_rect;
|
drawRect = sprites_rect;
|
||||||
drawRect.x += tpoint.x;
|
drawRect.x += tpoint.x;
|
||||||
drawRect.y += tpoint.y;
|
drawRect.y += tpoint.y;
|
||||||
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe],NULL, backBuffer, &drawRect, ct);
|
BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe],NULL, backBuffer, &drawRect, ct);
|
||||||
|
|
||||||
tpoint.x = xp+32;
|
tpoint.x = xp+32;
|
||||||
tpoint.y = yp - yoff;
|
tpoint.y = yp - yoff;
|
||||||
|
@ -1815,7 +1799,7 @@ void Graphics::drawentities()
|
||||||
drawRect = sprites_rect;
|
drawRect = sprites_rect;
|
||||||
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);
|
||||||
|
|
||||||
tpoint.x = xp;
|
tpoint.x = xp;
|
||||||
tpoint.y = yp+32 - yoff;
|
tpoint.y = yp+32 - yoff;
|
||||||
|
@ -1823,7 +1807,7 @@ void Graphics::drawentities()
|
||||||
drawRect = sprites_rect;
|
drawRect = sprites_rect;
|
||||||
drawRect.x += tpoint.x;
|
drawRect.x += tpoint.x;
|
||||||
drawRect.y += tpoint.y;
|
drawRect.y += tpoint.y;
|
||||||
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe+12],NULL, backBuffer, &drawRect, ct);
|
BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe+12],NULL, backBuffer, &drawRect, ct);
|
||||||
|
|
||||||
tpoint.x = xp+32;
|
tpoint.x = xp+32;
|
||||||
tpoint.y = yp+32 - yoff;
|
tpoint.y = yp+32 - yoff;
|
||||||
|
@ -1831,10 +1815,10 @@ void Graphics::drawentities()
|
||||||
drawRect = sprites_rect;
|
drawRect = sprites_rect;
|
||||||
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;
|
break;
|
||||||
case 10: // 2x1 Sprite
|
case 10: // 2x1 Sprite
|
||||||
if (!INBOUNDS_VEC(obj.entities[i].drawframe, (*spritesvec)))
|
if (!INBOUNDS_VEC(obj.entities[i].drawframe, spritesvec))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1846,7 +1830,7 @@ void Graphics::drawentities()
|
||||||
drawRect = sprites_rect;
|
drawRect = sprites_rect;
|
||||||
drawRect.x += tpoint.x;
|
drawRect.x += tpoint.x;
|
||||||
drawRect.y += tpoint.y;
|
drawRect.y += tpoint.y;
|
||||||
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe],NULL, backBuffer, &drawRect, ct);
|
BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe],NULL, backBuffer, &drawRect, ct);
|
||||||
|
|
||||||
tpoint.x = xp+32;
|
tpoint.x = xp+32;
|
||||||
tpoint.y = yp - yoff;
|
tpoint.y = yp - yoff;
|
||||||
|
@ -1854,14 +1838,14 @@ void Graphics::drawentities()
|
||||||
drawRect = sprites_rect;
|
drawRect = sprites_rect;
|
||||||
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;
|
break;
|
||||||
case 11: //The fucking elephant
|
case 11: //The fucking elephant
|
||||||
setcolreal(obj.entities[i].realcol);
|
setcolreal(obj.entities[i].realcol);
|
||||||
drawimagecol(3, xp, yp - yoff);
|
drawimagecol(3, xp, yp - yoff);
|
||||||
break;
|
break;
|
||||||
case 12: // Regular sprites that don't wrap
|
case 12: // Regular sprites that don't wrap
|
||||||
if (!INBOUNDS_VEC(obj.entities[i].drawframe, (*spritesvec)))
|
if (!INBOUNDS_VEC(obj.entities[i].drawframe, spritesvec))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1872,7 +1856,7 @@ void Graphics::drawentities()
|
||||||
drawRect = sprites_rect;
|
drawRect = sprites_rect;
|
||||||
drawRect.x += tpoint.x;
|
drawRect.x += tpoint.x;
|
||||||
drawRect.y += tpoint.y;
|
drawRect.y += tpoint.y;
|
||||||
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe],NULL, backBuffer, &drawRect, ct);
|
BlitSurfaceColoured(spritesvec[obj.entities[i].drawframe],NULL, backBuffer, &drawRect, ct);
|
||||||
|
|
||||||
|
|
||||||
//if we're outside the screen, we need to draw indicators
|
//if we're outside the screen, we need to draw indicators
|
||||||
|
@ -1920,7 +1904,7 @@ void Graphics::drawentities()
|
||||||
case 13:
|
case 13:
|
||||||
{
|
{
|
||||||
//Special for epilogue: huge hero!
|
//Special for epilogue: huge hero!
|
||||||
if (!INBOUNDS_VEC(obj.entities[i].drawframe, (*spritesvec)))
|
if (!INBOUNDS_VEC(obj.entities[i].drawframe, spritesvec))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1928,7 +1912,7 @@ void Graphics::drawentities()
|
||||||
tpoint.x = xp; tpoint.y = yp - yoff;
|
tpoint.x = xp; tpoint.y = yp - yoff;
|
||||||
setcolreal(obj.entities[i].realcol);
|
setcolreal(obj.entities[i].realcol);
|
||||||
SDL_Rect drawRect = {Sint16(obj.entities[i].xp ), Sint16(obj.entities[i].yp - yoff), Sint16(sprites_rect.x * 6), Sint16(sprites_rect.y * 6 ) };
|
SDL_Rect drawRect = {Sint16(obj.entities[i].xp ), Sint16(obj.entities[i].yp - yoff), Sint16(sprites_rect.x * 6), Sint16(sprites_rect.y * 6 ) };
|
||||||
SDL_Surface* TempSurface = ScaleSurface( (*spritesvec)[obj.entities[i].drawframe], 6 * sprites_rect.w,6* sprites_rect.h );
|
SDL_Surface* TempSurface = ScaleSurface( spritesvec[obj.entities[i].drawframe], 6 * sprites_rect.w,6* sprites_rect.h );
|
||||||
BlitSurfaceColoured(TempSurface, NULL , backBuffer, &drawRect, ct );
|
BlitSurfaceColoured(TempSurface, NULL , backBuffer, &drawRect, ct );
|
||||||
SDL_FreeSurface(TempSurface);
|
SDL_FreeSurface(TempSurface);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue