mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-09 18:39:45 +01:00
Collapse and invert if-statements in entity logic loops
This makes the code easier to read by reducing the amount of indentation it has.
This commit is contained in:
parent
c56cf009e7
commit
7e04908cd4
1 changed files with 14 additions and 12 deletions
|
@ -888,10 +888,12 @@ void gamelogic()
|
||||||
{
|
{
|
||||||
for (int i = obj.entities.size() - 1; i >= 0; i--)
|
for (int i = obj.entities.size() - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (obj.entities[i].isplatform)
|
if (!obj.entities[i].isplatform
|
||||||
{
|
|| SDL_abs(obj.entities[i].vx) >= 0.000001f)
|
||||||
if(SDL_abs(obj.entities[i].vx) < 0.000001f)
|
|
||||||
{
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
obj.removeblockat(obj.entities[i].xp, obj.entities[i].yp);
|
obj.removeblockat(obj.entities[i].xp, obj.entities[i].yp);
|
||||||
|
|
||||||
bool entitygone = obj.updateentities(i); // Behavioral logic
|
bool entitygone = obj.updateentities(i); // Behavioral logic
|
||||||
|
@ -907,17 +909,17 @@ void gamelogic()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(obj.horplatforms)
|
if(obj.horplatforms)
|
||||||
{
|
{
|
||||||
for (int ie = obj.entities.size() - 1; ie >= 0; ie--)
|
for (int ie = obj.entities.size() - 1; ie >= 0; ie--)
|
||||||
{
|
{
|
||||||
if (obj.entities[ie].isplatform)
|
if (!obj.entities[ie].isplatform
|
||||||
{
|
|| SDL_abs(obj.entities[ie].vy) >= 0.000001f)
|
||||||
if(SDL_abs(obj.entities[ie].vy) < 0.000001f)
|
|
||||||
{
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
obj.removeblockat(obj.entities[ie].xp, obj.entities[ie].yp);
|
obj.removeblockat(obj.entities[ie].xp, obj.entities[ie].yp);
|
||||||
|
|
||||||
bool entitygone = obj.updateentities(ie); // Behavioral logic
|
bool entitygone = obj.updateentities(ie); // Behavioral logic
|
||||||
|
@ -927,8 +929,6 @@ void gamelogic()
|
||||||
|
|
||||||
obj.hormovingplatformfix(ie);
|
obj.hormovingplatformfix(ie);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
//is the player standing on a moving platform?
|
//is the player standing on a moving platform?
|
||||||
int i = obj.getplayer();
|
int i = obj.getplayer();
|
||||||
float j = obj.entitycollideplatformfloor(i);
|
float j = obj.entitycollideplatformfloor(i);
|
||||||
|
@ -950,14 +950,16 @@ void gamelogic()
|
||||||
|
|
||||||
for (int ie = obj.entities.size() - 1; ie >= 0; ie--)
|
for (int ie = obj.entities.size() - 1; ie >= 0; ie--)
|
||||||
{
|
{
|
||||||
if (!obj.entities[ie].isplatform)
|
if (obj.entities[ie].isplatform)
|
||||||
{
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
bool entitygone = obj.updateentities(ie); // Behavioral logic
|
bool entitygone = obj.updateentities(ie); // Behavioral logic
|
||||||
if (entitygone) continue;
|
if (entitygone) continue;
|
||||||
obj.updateentitylogic(ie); // Basic Physics
|
obj.updateentitylogic(ie); // Basic Physics
|
||||||
obj.entitymapcollision(ie); // Collisions with walls
|
obj.entitymapcollision(ie); // Collisions with walls
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
obj.entitycollisioncheck(); // Check ent v ent collisions, update states
|
obj.entitycollisioncheck(); // Check ent v ent collisions, update states
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue