i had been at this for two days now.
i had been following this youtube tutorial for make a 2d game and so far i get past part 1 without much issues but my issue is now that on part 2 is that can't jump off ground but i can jump and unlimited amount of times as long as i don't tough the ground
here is the video
https://www.youtube.com/watch?v=3bHbydefA8c&list=PL14Yj-e2sgzxXOwdMYC0IDuG9m-VHEMW2&index=2
here is the code i have setup atm
//Get inputs
GetControls()
//x Movement
//Direction
moveDir = rightkey - leftkey;
//Get xspd
xspd = moveDir * moveSpd;
//x collision
var _subPixel = .5;
if place_meeting ( x + xspd, y, Obj_ground )
{
//Scoot up to wall precisely
var _pixelCheck = _subPixel \* sign(xspd);
while !place_meeting ( x + _pixelCheck, y, Obj_ground )
{
x += _pixelCheck;
}
//Set xspd to zero to "collide"
xspd = 0;
}
//Move
x += xspd;
//Y Movement
//Gravity
yspd += grav;
//reset//perpare jumping variables
if onGround
{
JumpCount = 0;
} else {
//if the player is in the air make sure they can't do a extra jump
if JumpCount == 0 { JumpCount = 1; };
}
//Jump
if jumpkeybuffered && JumpCount < JumpMax
{
//Reset the buffer
jumpkeybuffered = false;
jumpkeybufferTimer = 0;
//Increase the number of perfored jumps
JumpCount++;
//Set the jump hold timer
JumpHoldTimer = JumpHoldFrames;
}
//jump based on the timer/holding the button
if jumpkeybufferTimer > 0
{
//Constantly set the yspd to be jumping speed
yspd = jspd;
//Count the timer
JumpHoldTimer--;
}
//Y Collision and movement
// cap falling speed
if yspd > termVel { yspd = termVel; };
//Collision
var _subPixel = .5;
if place_meeting(x, y + yspd, Obj_ground )
{
//scoot up to wall preciselty
var _pixelCheck = _subPixel \* sign(yspd);
while !place_meeting( x, y + _pixelCheck, Obj_ground )
{
y += _pixelCheck;
}
//Set yspd to 0 to collide
yspd = 0;
}
//Set if i'm on the ground
if yspd >= 0 && place_meeting( x, y+1, Obj_ground )
{
onGround = true;
} else {
onGround = false;
}
//Move
y += yspd;>!​!<
can anyone please help me solve this issue