1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2025-01-08 18:09:45 +01:00

Wrap entities (#408)

Make entities able to wrap both vertically and horizontally, also add a case for when entities are wrapping both directions at the same time
This commit is contained in:
Tynan Richards 2020-07-29 18:17:28 +02:00 committed by GitHub
parent 178951e5e1
commit 8aac6a758d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1615,6 +1615,7 @@ void Graphics::drawentities()
switch (obj.entities[i].size)
{
case 0:
{
// Sprites
if (!INBOUNDS(obj.entities[i].drawframe, (*spritesvec)))
{
@ -1627,49 +1628,61 @@ void Graphics::drawentities()
drawRect = sprites_rect;
drawRect.x += tpoint.x;
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!
if (map.warpx ||
(map.towermode && !map.minitowermode
&& map.ypos >= 500 && map.ypos <= 5000)) //The "wrapping" area of the tower
point wrappedPoint;
bool wrapX = false;
bool wrapY = false;
wrappedPoint.x = tpoint.x;
if (tpoint.x < 0)
{
if (tpoint.x < 0)
{
tpoint.x += 320;
drawRect = sprites_rect;
drawRect.x += tpoint.x;
drawRect.y += tpoint.y;
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe],NULL, backBuffer, &drawRect, ct);
}
else if (tpoint.x > 300)
{
tpoint.x -= 320;
drawRect = sprites_rect;
drawRect.x += tpoint.x;
drawRect.y += tpoint.y;
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe],NULL, backBuffer, &drawRect, ct);
}
wrapX = true;
wrappedPoint.x += 320;
}
else if (map.warpy)
else if (tpoint.x > 300)
{
if (tpoint.y < 0)
{
tpoint.y += 230;
drawRect = sprites_rect;
drawRect.x += tpoint.x;
drawRect.y += tpoint.y;
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe],NULL, backBuffer, &drawRect, ct);
}
else if (tpoint.y > 210)
{
tpoint.y -= 230;
drawRect = sprites_rect;
drawRect.x += tpoint.x;
drawRect.y += tpoint.y;
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe],NULL, backBuffer, &drawRect, ct);
}
wrapX = true;
wrappedPoint.x -= 320;
}
wrappedPoint.y = tpoint.y;
if (tpoint.y < 0)
{
wrapY = true;
wrappedPoint.y += 230;
}
else if (tpoint.y > 210)
{
wrapY = true;
wrappedPoint.y -= 230;
}
bool isInWrappingAreaOfTower = map.towermode && !map.minitowermode && map.ypos >= 500 && map.ypos <= 5000;
if (wrapX && (map.warpx || isInWrappingAreaOfTower))
{
drawRect = sprites_rect;
drawRect.x += wrappedPoint.x;
drawRect.y += tpoint.y;
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe], NULL, backBuffer, &drawRect, ct);
}
if (wrapY && map.warpy)
{
drawRect = sprites_rect;
drawRect.x += tpoint.x;
drawRect.y += wrappedPoint.y;
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe], NULL, backBuffer, &drawRect, ct);
}
if (wrapX && wrapY && map.warpx && map.warpy)
{
drawRect = sprites_rect;
drawRect.x += wrappedPoint.x;
drawRect.y += wrappedPoint.y;
BlitSurfaceColoured((*spritesvec)[obj.entities[i].drawframe], NULL, backBuffer, &drawRect, ct);
}
break;
}
case 1:
// Tiles
if (!INBOUNDS(obj.entities[i].drawframe, tiles))