mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 17:49:43 +01:00
Condense some nested if-statements in gamelogic()
It's better to write if (cond1 && cond2) than it is to write if (cond1) { if (cond2) }.
This commit is contained in:
parent
3818340011
commit
e6c6c7cf60
1 changed files with 70 additions and 74 deletions
|
@ -1037,8 +1037,66 @@ void gamelogic()
|
|||
{
|
||||
for (size_t i = 0; i < obj.entities.size(); i++)
|
||||
{
|
||||
if(obj.entities[i].type<50){ //Don't warp warp lines
|
||||
if (obj.entities[i].size < 12) //Don't wrap SWN enemies
|
||||
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)
|
||||
{
|
||||
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 (game.roomx == 118 && game.roomy == 102 && obj.entities[i].rule==1 && !map.custommode)
|
||||
{
|
||||
//ascii snakes
|
||||
if (obj.entities[i].xp <= -80)
|
||||
{
|
||||
obj.entities[i].xp += 400;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (obj.entities[i].xp > 320)
|
||||
{
|
||||
obj.entities[i].xp -= 400;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (obj.entities[i].xp <= -10)
|
||||
{
|
||||
|
@ -1055,67 +1113,6 @@ void gamelogic()
|
|||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < obj.entities.size(); i++)
|
||||
{
|
||||
|
||||
if(obj.entities[i].type<50){ //Don't warp warp lines
|
||||
if (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)
|
||||
{
|
||||
for (size_t i = 0; i < obj.entities.size(); i++)
|
||||
{
|
||||
if(obj.entities[i].type<50){ //Don't warp warp lines
|
||||
if (obj.entities[i].size < 12) //Don't wrap SWN enemies
|
||||
{
|
||||
if (game.roomx == 118 && game.roomy == 102 && obj.entities[i].rule==1 && !map.custommode)
|
||||
{
|
||||
//ascii snakes
|
||||
if (obj.entities[i].xp <= -80)
|
||||
{
|
||||
obj.entities[i].xp += 400;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (obj.entities[i].xp > 320)
|
||||
{
|
||||
obj.entities[i].xp -= 400;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (obj.entities[i].xp <= -10)
|
||||
{
|
||||
obj.entities[i].xp += 320;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (obj.entities[i].xp > 310)
|
||||
{
|
||||
obj.entities[i].xp -= 320;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int player = obj.getplayer();
|
||||
if (game.door_down > -2 && obj.entities[player].yp >= 238)
|
||||
{
|
||||
|
@ -1150,19 +1147,18 @@ void gamelogic()
|
|||
for (size_t i = 0; i < obj.entities.size(); i++)
|
||||
{
|
||||
|
||||
if(obj.entities[i].type<50){ //Don't warp warp lines
|
||||
if(obj.entities[i].rule!=0)
|
||||
if(obj.entities[i].type<50 //Don't warp warp lines
|
||||
&&obj.entities[i].rule!=0)
|
||||
{
|
||||
if (obj.entities[i].xp <= -30)
|
||||
{
|
||||
if (obj.entities[i].xp <= -30)
|
||||
obj.entities[i].xp += 350;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (obj.entities[i].xp > 320)
|
||||
{
|
||||
obj.entities[i].xp += 350;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (obj.entities[i].xp > 320)
|
||||
{
|
||||
obj.entities[i].xp -= 350;
|
||||
}
|
||||
obj.entities[i].xp -= 350;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue