1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-23 01:59: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,6 +2210,8 @@ 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)
{ {
@ -2226,28 +2228,38 @@ void gameinput(void)
if (game.jumppressed > 0) if (game.jumppressed > 0)
{ {
game.jumppressed--; game.jumppressed--;
if (obj.entities[ie].onground>0 && game.gravitycontrol == 0) if (obj.entities[obj.getplayer()].onground>0 && game.gravitycontrol == 0)
{ {
game.gravitycontrol = 1; game.gravitycontrol = 1;
for (size_t ie = 0; ie < obj.entities.size(); ++ie)
{
if (obj.entities[ie].rule == 0)
{
obj.entities[ie].vy = -4; obj.entities[ie].vy = -4;
obj.entities[ie].ay = -3; obj.entities[ie].ay = -3;
}
}
music.playef(0); music.playef(0);
game.jumppressed = 0; game.jumppressed = 0;
game.totalflips++; game.totalflips++;
} }
if (obj.entities[ie].onroof>0 && game.gravitycontrol == 1) if (obj.entities[obj.getplayer()].onroof>0 && game.gravitycontrol == 1)
{ {
game.gravitycontrol = 0; 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].vy = 4;
obj.entities[ie].ay = 3; obj.entities[ie].ay = 3;
}
}
music.playef(1); music.playef(1);
game.jumppressed = 0; game.jumppressed = 0;
game.totalflips++; game.totalflips++;
} }
} }
} }
}
}
if (!has_control) if (!has_control)
{ {