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

Use case-switch for entityclass::collisioncheck()

This makes each case in the function less verbose.
This commit is contained in:
Misa 2020-09-05 17:37:57 -07:00 committed by Ethan Lee
parent b5806c8bb0
commit 5e29d676e9

View File

@ -4689,8 +4689,14 @@ void entityclass::collisioncheck(int i, int j, bool scm /*= false*/)
return; return;
} }
if (entities[j].rule == 1 && entities[j].harmful) switch (entities[j].rule)
{ {
case 1:
if (!entities[j].harmful)
{
break;
}
//person i hits enemy or enemy bullet j //person i hits enemy or enemy bullet j
if (entitycollide(i, j) && !map.invincibility) if (entitycollide(i, j) && !map.invincibility)
{ {
@ -4720,20 +4726,17 @@ void entityclass::collisioncheck(int i, int j, bool scm /*= false*/)
game.scmhurt = scm; game.scmhurt = scm;
} }
} }
} break;
if (entities[j].rule == 2) //Moving platforms case 2: //Moving platforms
{
if (entitycollide(i, j)) removeblockat(entities[j].xp, entities[j].yp); if (entitycollide(i, j)) removeblockat(entities[j].xp, entities[j].yp);
} break;
if (entities[j].rule == 3) //Entity to entity case 3: //Entity to entity
{
if(entities[j].onentity>0) if(entities[j].onentity>0)
{ {
if (entitycollide(i, j)) entities[j].state = entities[j].onentity; if (entitycollide(i, j)) entities[j].state = entities[j].onentity;
} }
} break;
if (entities[j].rule == 4) //Person vs horizontal line! case 4: //Person vs horizontal line!
{
if(game.deathseq==-1) if(game.deathseq==-1)
{ {
//Here we compare the person's old position versus his new one versus the line. //Here we compare the person's old position versus his new one versus the line.
@ -4759,9 +4762,8 @@ void entityclass::collisioncheck(int i, int j, bool scm /*= false*/)
} }
} }
} }
} break;
if (entities[j].rule == 5) //Person vs vertical gravity/warp line! case 5: //Person vs vertical gravity/warp line!
{
if(game.deathseq==-1) if(game.deathseq==-1)
{ {
if(entities[j].onentity>0) if(entities[j].onentity>0)
@ -4773,9 +4775,8 @@ void entityclass::collisioncheck(int i, int j, bool scm /*= false*/)
} }
} }
} }
} break;
if (entities[j].rule == 6) //Person versus crumbly blocks! Special case case 6: //Person versus crumbly blocks! Special case
{
if (entities[j].onentity > 0) if (entities[j].onentity > 0)
{ {
//ok; only check the actual collision if they're in a close proximity //ok; only check the actual collision if they're in a close proximity
@ -4789,9 +4790,8 @@ void entityclass::collisioncheck(int i, int j, bool scm /*= false*/)
} }
} }
} }
} break;
if (entities[j].rule == 7) // Person versus horizontal warp line, pre-2.1 case 7: // Person versus horizontal warp line, pre-2.1
{
if (game.glitchrunnermode if (game.glitchrunnermode
&& game.deathseq == -1 && game.deathseq == -1
&& entities[j].onentity > 0 && entities[j].onentity > 0
@ -4799,5 +4799,6 @@ void entityclass::collisioncheck(int i, int j, bool scm /*= false*/)
{ {
entities[j].state = entities[j].onentity; entities[j].state = entities[j].onentity;
} }
break;
} }
} }