J
jwrose
Guest
Hello!
First time posting- I'm working on my first game in GameMaker after doing tutorials. I'm trying to make a somewhat unique jump behavior where a tap does a fairly normal gravity based jump and holding makes you go up a bit more (like a double jump) but then I want the y value to remain constant so the jump "levels-off" and the character basically hovers in place for a few seconds before dropping. I have the basics working but I can't get this hover effect to work. I best I've gotten is a double jump. Below is the related code. Any help would be appreciated. I've done some programming in the past, but I'm not a programmer per se- so I'm sure I'm overlooking something that will be easy for a more experienced programmer.
button_press = keyboard_check_pressed(vk_space);
button_held = keyboard_check(vk_space);
//this decides if the button is simply pressed or held:
if(button_press)
{
button_timer = 0.1;
}
if(button_held)
{
button_timer += 0.1;
}
if(button_timer <= 1 and button_timer> 0)
{
button_state = "pressed";
}
if(button_timer > 1.1)
{
button_state = "held";
}
//Jump code for press, this works fine
if (button_press = true) && (place_meeting(x,y+vsp,oWall))
{
vsp = -18;
jetpack = 1;
}
//controls hover jump. This is the part that I'm having trouble with.
if (button_state = "held") && (jetpack == 1)
{
// I created a loop to try to control what happens during this "second jump". I've tried tons of stuff here. This is one version of what I've come up with.
var glassceiling = 0
for (glassceiling = 0; glassceiling < 1000; glassceiling += 1)
{
vsp = +vsp - grv;
button_timer = button_timer - 0.1;
}
if (button_timer <= 0.1)
//I'm using this just to return everything to defaults. I'm played around with all of these variables at one time or another, so they're mostly unnecessary, bit I left them for now.
{
button_held = false;
vsp = -17;
grv = 1.1;
walksp = 7;
jetpack = 0;
keyboard_key_release(vk_space);
}
}
Appreciate any help! Thanks everyone!
First time posting- I'm working on my first game in GameMaker after doing tutorials. I'm trying to make a somewhat unique jump behavior where a tap does a fairly normal gravity based jump and holding makes you go up a bit more (like a double jump) but then I want the y value to remain constant so the jump "levels-off" and the character basically hovers in place for a few seconds before dropping. I have the basics working but I can't get this hover effect to work. I best I've gotten is a double jump. Below is the related code. Any help would be appreciated. I've done some programming in the past, but I'm not a programmer per se- so I'm sure I'm overlooking something that will be easy for a more experienced programmer.
button_press = keyboard_check_pressed(vk_space);
button_held = keyboard_check(vk_space);
//this decides if the button is simply pressed or held:
if(button_press)
{
button_timer = 0.1;
}
if(button_held)
{
button_timer += 0.1;
}
if(button_timer <= 1 and button_timer> 0)
{
button_state = "pressed";
}
if(button_timer > 1.1)
{
button_state = "held";
}
//Jump code for press, this works fine
if (button_press = true) && (place_meeting(x,y+vsp,oWall))
{
vsp = -18;
jetpack = 1;
}
//controls hover jump. This is the part that I'm having trouble with.
if (button_state = "held") && (jetpack == 1)
{
// I created a loop to try to control what happens during this "second jump". I've tried tons of stuff here. This is one version of what I've come up with.
var glassceiling = 0
for (glassceiling = 0; glassceiling < 1000; glassceiling += 1)
{
vsp = +vsp - grv;
button_timer = button_timer - 0.1;
}
if (button_timer <= 0.1)
//I'm using this just to return everything to defaults. I'm played around with all of these variables at one time or another, so they're mostly unnecessary, bit I left them for now.
{
button_held = false;
vsp = -17;
grv = 1.1;
walksp = 7;
jetpack = 0;
keyboard_key_release(vk_space);
}
}
Appreciate any help! Thanks everyone!