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