D
Dibidoolandas
Guest
I'm having a really difficult time with adding trampolines and I'm not sure why. Sadly explaining it isn't going to be super easy but I'll do my best. Basically, I have code that tells me player to not jump as high if you're not holding the jump key in his "air" state. Here it is:
Now here's the thing... I like this code, but I just want my trampoline jump to have a flat value that it pushes the player upward. So here's my code for landing on a trampoline, triggered from the trampoline object.
Generally when you hit the jump key, it just runs that vsp -= spd_jump code once. But in this case, the trampoline tells it to run that code until the alarm turns it off at room_speed/5. So we end up jumping higher.
The problem comes in when I try to turn off that first code I posted. My first (and really only) though for how to do this was to just create a conditional like so.
For reasons I simply cannot wrap my head around, this doesn't work. I have no idea why, but if I don't hold the jump key while bouncing on the trampoline object, it cuts my jump speed in half still.
I did a test where I wrote the following instead of if bounce = false:
This is hacky as Hell, but basically if my player is within 70 pixels to the left or right of the trampoline (obj_spring), it turns off my short jump. So why in the world is bounce = false not doing it?
It's probably glaringly obvious, but it's driving me nuts that I can't get this. I really don't want to have to create a new state just to handle trampolines. Any help would be greatly appreciated. Thanks.
Code:
if ((vsp < 0) && (!key_jump_held)) //If we're moving up and not holding the jump button
{
vsp = max(vsp,-spd_jump/2); //Cut our jump speed in half
}
Code:
if (instance_place(x,y-1,obj_player))
{
obj_player.bounce = true;
alarm[0] = room_speed/5;
}
if (obj_player.bounce = true)
{
obj_player.vsp -= obj_player.spd_jump;
}
The problem comes in when I try to turn off that first code I posted. My first (and really only) though for how to do this was to just create a conditional like so.
Code:
if (bounce = false)
{
if ((vsp < 0) && (!key_jump_held)) //If we're moving up and not holding the jump button
{
vsp = max(vsp,-spd_jump/2); //Cut our jump speed in half
}
}
I did a test where I wrote the following instead of if bounce = false:
Code:
if !((x > obj_spring.x - 35) && (x < obj_spring.x + 35))
It's probably glaringly obvious, but it's driving me nuts that I can't get this. I really don't want to have to create a new state just to handle trampolines. Any help would be greatly appreciated. Thanks.