1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 17:49:43 +01:00

Split flip logic from player input logic

Closes #484

Flipping only applies momentum to the player entity currently being
processed. This normally wouldn't be a problem. However, flipping
involves global state, and only one flip can occur per frame. This means
that additional player entities don't get this boost of momentum, which
feels somewhat unnatural during gameplay.

This commit fixes this by splitting flip logic out of the loop over
player entities, and applying the flip momentum to all player entities.
This commit is contained in:
leo60228 2020-09-22 15:24:23 -04:00 committed by Misa Elizabeth Kai
parent 416fe00c9d
commit 1eb8570329

View file

@ -2210,41 +2210,53 @@ void gameinput(void)
obj.entities[ie].ax = 3; obj.entities[ie].ax = 3;
obj.entities[ie].dir = 1; obj.entities[ie].dir = 1;
} }
}
}
if (!game.press_action) if (!game.press_action)
{ {
game.jumppressed = 0; game.jumppressed = 0;
game.jumpheld = false; game.jumpheld = false;
} }
if (game.press_action && !game.jumpheld) if (game.press_action && !game.jumpheld)
{ {
game.jumppressed = 5; game.jumppressed = 5;
game.jumpheld = true; game.jumpheld = true;
} }
if (game.jumppressed > 0) if (game.jumppressed > 0)
{
game.jumppressed--;
if (obj.entities[obj.getplayer()].onground>0 && game.gravitycontrol == 0)
{
game.gravitycontrol = 1;
for (size_t ie = 0; ie < obj.entities.size(); ++ie)
{ {
game.jumppressed--; if (obj.entities[ie].rule == 0)
if (obj.entities[ie].onground>0 && game.gravitycontrol == 0)
{ {
game.gravitycontrol = 1;
obj.entities[ie].vy = -4; obj.entities[ie].vy = -4;
obj.entities[ie].ay = -3; obj.entities[ie].ay = -3;
music.playef(0);
game.jumppressed = 0;
game.totalflips++;
}
if (obj.entities[ie].onroof>0 && game.gravitycontrol == 1)
{
game.gravitycontrol = 0;
obj.entities[ie].vy = 4;
obj.entities[ie].ay = 3;
music.playef(1);
game.jumppressed = 0;
game.totalflips++;
} }
} }
music.playef(0);
game.jumppressed = 0;
game.totalflips++;
}
if (obj.entities[obj.getplayer()].onroof>0 && game.gravitycontrol == 1)
{
game.gravitycontrol = 0;
for (size_t ie = 0; ie < obj.entities.size(); ++ie)
{
if (obj.entities[ie].rule == 0)
{
obj.entities[ie].vy = 4;
obj.entities[ie].ay = 3;
}
}
music.playef(1);
game.jumppressed = 0;
game.totalflips++;
} }
} }
} }