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

Split out tap_left and tap_right from player input loop

The game will freeze the player immediately if they release a
directional button within 3 frames of pressing it. Similar to flipping,
this involves global state, and will only apply to the first player
entity.
This commit is contained in:
leo60228 2020-09-22 15:44:20 -04:00 committed by Misa Elizabeth Kai
parent 1eb8570329
commit cd4ce05cb3

View file

@ -2168,38 +2168,6 @@ void gameinput(void)
} }
} }
if (game.press_left)
{
game.tapleft++;
}
else
{
if (game.tapleft <= 4 && game.tapleft > 0)
{
if (obj.entities[ie].vx < 0.0f)
{
obj.entities[ie].vx = 0.0f;
}
}
game.tapleft = 0;
}
if (game.press_right)
{
game.tapright++;
}
else
{
if (game.tapright <= 4 && game.tapright > 0)
{
if (obj.entities[ie].vx > 0.0f)
{
obj.entities[ie].vx = 0.0f;
}
}
game.tapright = 0;
}
if(game.press_left) if(game.press_left)
{ {
obj.entities[ie].ax = -3; obj.entities[ie].ax = -3;
@ -2213,6 +2181,49 @@ void gameinput(void)
} }
} }
if (game.press_left)
{
game.tapleft++;
}
else
{
if (game.tapleft <= 4 && game.tapleft > 0)
{
for (size_t ie = 0; ie < obj.entities.size(); ++ie)
{
if (obj.entities[ie].rule == 0)
{
if (obj.entities[ie].vx < 0.0f)
{
obj.entities[ie].vx = 0.0f;
}
}
}
}
game.tapleft = 0;
}
if (game.press_right)
{
game.tapright++;
}
else
{
if (game.tapright <= 4 && game.tapright > 0)
{
for (size_t ie = 0; ie < obj.entities.size(); ++ie)
{
if (obj.entities[ie].rule == 0)
{
if (obj.entities[ie].vx > 0.0f)
{
obj.entities[ie].vx = 0.0f;
}
}
}
}
game.tapright = 0;
}
if (!game.press_action) if (!game.press_action)
{ {
game.jumppressed = 0; game.jumppressed = 0;