mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-08 18:09:45 +01:00
Factor out entity drawing to separate function
This makes it easy to re-use without duplicating code.
This commit is contained in:
parent
fd53278163
commit
e809cc0615
2 changed files with 30 additions and 17 deletions
|
@ -1593,6 +1593,27 @@ void Graphics::drawtrophytext()
|
|||
|
||||
void Graphics::drawentities()
|
||||
{
|
||||
const int yoff = map.towermode ? lerp(map.oldypos, map.ypos) : 0;
|
||||
|
||||
for (int i = obj.entities.size() - 1; i >= 0; i--)
|
||||
{
|
||||
drawentity(i, yoff);
|
||||
}
|
||||
}
|
||||
|
||||
void Graphics::drawentity(const int i, const int yoff)
|
||||
{
|
||||
if (!INBOUNDS_VEC(i, obj.entities))
|
||||
{
|
||||
WHINE_ONCE("drawentity() out-of-bounds!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (obj.entities[i].invis)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
point tpoint;
|
||||
|
||||
SDL_Rect drawRect;
|
||||
|
@ -1610,15 +1631,6 @@ void Graphics::drawentities()
|
|||
|
||||
std::vector<SDL_Surface*>& spritesvec = flipmode ? flipsprites : sprites;
|
||||
|
||||
const int yoff = map.towermode ? lerp(map.oldypos, map.ypos) : 0;
|
||||
|
||||
for (int i = obj.entities.size() - 1; i >= 0; i--)
|
||||
{
|
||||
if (obj.entities[i].invis)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const int xp = lerp(obj.entities[i].lerpoldxp, obj.entities[i].xp);
|
||||
const int yp = lerp(obj.entities[i].lerpoldyp, obj.entities[i].yp);
|
||||
|
||||
|
@ -1629,7 +1641,7 @@ void Graphics::drawentities()
|
|||
// Sprites
|
||||
if (!INBOUNDS_VEC(obj.entities[i].drawframe, spritesvec))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
tpoint.x = xp;
|
||||
tpoint.y = yp - yoff;
|
||||
|
@ -1697,7 +1709,7 @@ void Graphics::drawentities()
|
|||
// Tiles
|
||||
if (!INBOUNDS_VEC(obj.entities[i].drawframe, tiles))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
tpoint.x = xp;
|
||||
tpoint.y = yp - yoff;
|
||||
|
@ -1712,7 +1724,7 @@ void Graphics::drawentities()
|
|||
// Special: Moving platform, 4 tiles or 8 tiles
|
||||
if (!INBOUNDS_VEC(obj.entities[i].drawframe, tilesvec))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
tpoint.x = xp;
|
||||
tpoint.y = yp - yoff;
|
||||
|
@ -1779,7 +1791,7 @@ void Graphics::drawentities()
|
|||
case 9: // Really Big Sprite! (2x2)
|
||||
if (!INBOUNDS_VEC(obj.entities[i].drawframe, spritesvec))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
setcolreal(obj.entities[i].realcol);
|
||||
|
||||
|
@ -1818,7 +1830,7 @@ void Graphics::drawentities()
|
|||
case 10: // 2x1 Sprite
|
||||
if (!INBOUNDS_VEC(obj.entities[i].drawframe, spritesvec))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
setcolreal(obj.entities[i].realcol);
|
||||
|
||||
|
@ -1845,7 +1857,7 @@ void Graphics::drawentities()
|
|||
case 12: // Regular sprites that don't wrap
|
||||
if (!INBOUNDS_VEC(obj.entities[i].drawframe, spritesvec))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
tpoint.x = xp;
|
||||
tpoint.y = yp - yoff;
|
||||
|
@ -1904,7 +1916,7 @@ void Graphics::drawentities()
|
|||
//Special for epilogue: huge hero!
|
||||
if (!INBOUNDS_VEC(obj.entities[i].drawframe, spritesvec))
|
||||
{
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
|
||||
tpoint.x = xp; tpoint.y = yp - yoff;
|
||||
|
@ -1919,7 +1931,6 @@ void Graphics::drawentities()
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Graphics::drawbackground( int t )
|
||||
|
|
|
@ -140,6 +140,8 @@ public:
|
|||
|
||||
void drawentities();
|
||||
|
||||
void drawentity(const int i, const int yoff);
|
||||
|
||||
void drawtrophytext();
|
||||
|
||||
void bigrprint(int x, int y, std::string& t, int r, int g, int b, bool cen = false, float sc = 2);
|
||||
|
|
Loading…
Reference in a new issue