How do you make an object 'jump' in a Game Maker game?

1 answer

Answer

1230979

2026-04-05 01:25

+ Follow

The easiest way to jump is by entering this code in the correct places. You could set the gravity but this way is easier. This will work in both the pro and lite

put this code in you Create event of you player

falling=false; //Variable for Falling

hitting=false; //Variable for if you are hitting something

grav=7; //Gravity

movement=6; //Speed at which you move

jump=0; //Used for jumping

jumping=false; //If you are jumping or not

space=false; //if space is pressed

doublejumping=false //if doublejumping

doublej=0; //for doublejumping

put this code in you step event of you player

//FALLING:

if(!collision_point(x,y,ground,true,false) && !jumping && !doublejumping) //not touching ground, or jumping{

y+=grav; //Move down the number gravity

grav=7; //Keeps gravity set

falling=true; //says the player is falling

}

if(keyboard_check_pressed(vk_space)){ //if keypressed SPACE

space=true //space=true. For other purposes

}

if(keyboard_check_released(vk_space)){ //if space not pressed

space=false //space is false

}

if(space=true && jumping==false) //if space is pressed, and jumping is false{

jumping=true; //jumps

space=false //space no longer pressed

}

if(space=true && jumping==true && doublejumping=false) //if space pressed, player jumping, and not doublejumping {

doublejumping=true //doublejumps

jumping=false //no more jumping

}

if(jumping) //if jumping is true{

y-=jump; //go up jump

jump-=.5; //lower jump a little

if(jump<0) && doublejumping=false //if jump is nil and not doublejumping {

falling=true; //fall

}

if(jump<-10) { //if jump is below -10, set it to 10

jump=-10;

}

}

if(doublejumping) //if doublejumping{

y-=doublej; //go up doublej

doublej-=.5; //lower doublej a little

if(doublej<0) { //is doublej is nil, fall

falling=true;

}

if(doublej<-10) { //if doublej is below -10, set it to -10

doublej=-10;

}

}

if(collision_point(x,y,ground,true,false) && falling) { //if touching ground and falling

jump=10; //jump is 10, for next jump

jumping=false; //No longer jumping

falling=false; //no longer falling

doublejumping=false //no longer doublejumping

}

if(keyboard_check(vk_left)) { //MOVEMENT. if left key is pressed

x-=movement; //move left

}

if(keyboard_check(vk_right)) { //if right pressed

x+=movement; //move right

}

if falling=false && jumping=true { //if falling is false, and jumping is true

{

doublej=10; //doublej is 10

}

}

Done. if you r having trouble download the example

http://www.willhostforfood.com/users/warsome/doublejumpgrav.gmk

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.