1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-23 04:58:30 +02:00

De-dupe screen transition / warping logic

I noticed that the code for going to the adjacent room when offscreen
and for warping instead if the room is warping was a bit
copy-and-pasted. To clean up the code a bit, there's now 5 separate
checks in gamelogic():

if (map.warpx)
if (map.warpy)
if (map.warpy && !map.warpx)
if (!map.warpy)
if (!map.warpx)

I made sure to preserve the previous weird horizontal warping behavior
that happens with vertical warping (thus the middle one), and to
preserve the frame ordering just in case there's something dependent on
the frame ordering.

The frame ordering is that first it will warp you horizontally, if
applicable, then it will warp you vertically, if applicable. Then if you
have vertical warping only, that weird horizontal warp. Then it will
screen transition you vertically, if applicable. Then it will screen
transition you horizontally, if applicable.

To explain the weird horizontal warp with the vertical warp: apparently
if an entity is far offscreen enough, and if that entity is not the
player, it will be warped horizontally during a vertical warp. The
points at which it will warp is 30 pixels farther out than normal
horizontal warping.

I think someone ran into this before, but my memory is fuzzy. The best I
can recall is that they were probably createentity()ing a high-speed
horizontally-moving enemy in a vertically warping room, only to discover
that said enemy kept warping horizontally.
This commit is contained in:
Misa 2020-04-04 12:39:17 -07:00 committed by Ethan Lee
parent 7899cb8088
commit 79a54f23e6

View File

@ -1033,42 +1033,7 @@ void gamelogic()
}
//Finally: Are we changing room?
if (map.warpx && map.warpy)
{
for (size_t i = 0; i < obj.entities.size(); i++)
{
if(obj.entities[i].type<50 //Don't warp warp lines
&& obj.entities[i].size < 12) //Don't wrap SWN enemies
{
if (obj.entities[i].xp <= -10)
{
obj.entities[i].xp += 320;
}
else if (obj.entities[i].xp > 310)
{
obj.entities[i].xp -= 320;
}
}
}
for (size_t i = 0; i < obj.entities.size(); i++)
{
if(obj.entities[i].type<50 //Don't warp warp lines
&& obj.entities[i].size < 12) //Don't wrap SWN enemies
{
if (obj.entities[i].yp <= -12)
{
obj.entities[i].yp += 232;
}
else if (obj.entities[i].yp > 226)
{
obj.entities[i].yp -= 232;
}
}
}
}
else if (map.warpx)
if (map.warpx)
{
for (size_t i = 0; i < obj.entities.size(); i++)
{
@ -1100,20 +1065,9 @@ void gamelogic()
}
}
}
int player = obj.getplayer();
if (game.door_down > -2 && obj.entities[player].yp >= 238)
{
obj.entities[player].yp -= 240;
map.gotoroom(game.roomx, game.roomy + 1);
}
if (game.door_up > -2 && obj.entities[player].yp < -2)
{
obj.entities[player].yp += 240;
map.gotoroom(game.roomx, game.roomy - 1);
}
}
else if (map.warpy)
if (map.warpy)
{
for (size_t i = 0; i < obj.entities.size(); i++)
{
@ -1128,7 +1082,10 @@ void gamelogic()
}
}
}
}
if (map.warpy && !map.warpx)
{
for (size_t i = 0; i < obj.entities.size(); i++)
{
@ -1145,20 +1102,9 @@ void gamelogic()
}
}
}
int player = obj.getplayer();
if (game.door_left > -2 && obj.entities[player].xp < -14)
{
obj.entities[player].xp += 320;
map.gotoroom(game.roomx - 1, game.roomy);
}
if (game.door_right > -2 && obj.entities[player].xp >= 308)
{
obj.entities[player].xp -= 320;
map.gotoroom(game.roomx + 1, game.roomy);
}
}
else
if (!map.warpy)
{
//Normal! Just change room
int player = obj.getplayer();
@ -1172,6 +1118,12 @@ void gamelogic()
obj.entities[player].yp += 240;
map.gotoroom(game.roomx, game.roomy - 1);
}
}
if (!map.warpx)
{
//Normal! Just change room
int player = obj.getplayer();
if (game.door_left > -2 && obj.entities[player].xp < -14)
{
obj.entities[player].xp += 320;