Wow, it works great! Thank you very much.
I also made trampolines in my game by adding this to your script:
if !place_meeting(x, y+1, obj_block) && (!place_meeting(x,y+1,obj_block_through) or place_meeting(x,y,obj_block_through))
{
grav = 2;
vspd += grav;
}
else if place_meeting(x, y+1, obj_block_jump)
{
vspd = -30;
}
else
{
grav = 0;
vspd = 0;
if keyboard_check_pressed(vk_up)
{
vspd = -22;
}
}And also give
obj_block_jump a parent:
obj_block.
Could you also explain moving platforms?
EditI also added another future to the jumpthrough platform:
if !place_meeting(x, y+1, obj_block) && (!place_meeting(x,y+1,obj_block_through) or place_meeting(x,y,obj_block_through)) // if we are in the air
{
grav = 2; // set the gravity to .5
vspd += grav; // add .5 to our vspd once every step
}
else if place_meeting(x, y+1, obj_block_jump)
{
vspd = -30;
}
else if place_meeting(x, y+1, obj_block_through) && keyboard_check_pressed(vk_down)
{
self.y = (other.y+1)
}
else // else if we are on the ground
{
grav = 0; // set the gravity to 0
vspd = 0; // set vspd to 0 to stop moving
if keyboard_check_pressed(vk_up) // since we are on the ground, we can handle jumping here, so check if we pressed up
{
vspd = -22; // set the vspd to -8, which will make us jump
}
}This will make the
obj_player go through the jumpthrough platform (fall down) when you press the down arrow while standing on a jumpthrough platform.
But I know this isn't a good way because the player could get stuck, what do you suggest to do here? This is the part of the code I have added:
else if place_meeting(x, y+1, obj_block_through) && keyboard_check_pressed(vk_down)
{
self.y = (other.y+1)
}Kind regards,
Jeesie
Edited by Jeesie, 22 April 2012 - 08:06 PM.