Shortly after my AreThingsOverlapping ordeal, I decided to start working on the gravity for my quite possibly futile attempt at a combat system. Obviously, the very fabric of fate appears to be against it, as I have now encountered yet another nonsensical error. Here is the code for the gravity:
function repeatedly_execute_always()
{
catchY[player.ID] = 198;
if (player.y != catchY[player.ID])
{gravity[player.ID]= -1;
player.y=player.y-gravSpeed[player.ID];
gravSpeed[player.ID]=gravSpeed[player.ID]+gravity[player.ID];
if (gravity[player.ID] < -1)
gravity[player.ID] = -1;
}
if (player.y > catchY[player.ID])
player.y = catchY[player.ID];
if (IsKeyPressed(eKeyUpArrow)==1)
player.y -= 20;
}
Now, "catchY" is an array I use in the place of a conventional floor. The "if" line underneath it stops the downward motion if the player is at "catchY" (meaning that it only simulates gravity instead of actually making it realistic, but whatever) while moving it downwards if it isn't. The next "if" statement keeps gravity from becoming uncontrollably fast. The next one basically keeps the player from falling through the floor, and the last one is simply for jumping.
So, my problem is this: I can jump once, everything seems dandy, then the character just freezes in midair, the sprite bottom at y coordinate 177. When I release the button, I simply teleport to catchY (which is 198), and every time I try to jump after that I just teleport up to 177 again.
Oddly enough, when I deleted this line (I think):
gravSpeed[player.ID]=gravSpeed[player.ID]+gravity[player.ID];
And replaced the gravSpeed with gravity in the line before it, this no longer happened; however, understandably enough, I would no longer fall without releasing the button.
Sorry for the long post, but I've been stumped on this for months and didn't really see an alternative.
Thanks for putting up with my bizarre problems.
function repeatedly_execute_always()
{
catchY[player.ID] = 198;
if (player.y != catchY[player.ID])
{gravity[player.ID]= -1;
player.y=player.y-gravSpeed[player.ID];
gravSpeed[player.ID]=gravSpeed[player.ID]+gravity[player.ID];
if (gravity[player.ID] < -1)
gravity[player.ID] = -1;
}
if (player.y > catchY[player.ID])
player.y = catchY[player.ID];
if (IsKeyPressed(eKeyUpArrow)==1)
player.y -= 20;
}
Now, "catchY" is an array I use in the place of a conventional floor. The "if" line underneath it stops the downward motion if the player is at "catchY" (meaning that it only simulates gravity instead of actually making it realistic, but whatever) while moving it downwards if it isn't. The next "if" statement keeps gravity from becoming uncontrollably fast. The next one basically keeps the player from falling through the floor, and the last one is simply for jumping.
So, my problem is this: I can jump once, everything seems dandy, then the character just freezes in midair, the sprite bottom at y coordinate 177. When I release the button, I simply teleport to catchY (which is 198), and every time I try to jump after that I just teleport up to 177 again.
Oddly enough, when I deleted this line (I think):
gravSpeed[player.ID]=gravSpeed[player.ID]+gravity[player.ID];
And replaced the gravSpeed with gravity in the line before it, this no longer happened; however, understandably enough, I would no longer fall without releasing the button.
Sorry for the long post, but I've been stumped on this for months and didn't really see an alternative.
Thanks for putting up with my bizarre problems.