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:
parent
416fe00c9d
commit
1eb8570329
1 changed files with 38 additions and 26 deletions
|
@ -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++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue