Hi Shadow000, welcome to the forums!!! Here is a small program I wrote that demonstrates jumping, I've added comments to explain what each part of the program does.
Here it is
Rem ***** Main Source File *****
sync on : sync rate 60
x as integer = 320 // x position on screen
y as integer = 380 // y position on screen
xspeed as integer = 1 // the speed at which x is increased or decreased
yspeed as integer = 2 // the speed at which y is increased or decreased
jump as boolean = 0 // check whether the user can jump or not
y2 as integer // a variable to store the y position when the jump starts
do
// clear the screen
cls
// draw the ground
line 0, 410, 640, 410
// move the ball left
if leftkey()=1
dec x, xspeed
endif
// move the ball right
if rightkey()=1
inc x, xspeed
endif
// draw the circle
circle x, y, 10
// jump upon pressing spacekey
// checks where jump is zero so the user doesn't jump while jumping
if spacekey()=1 and jump = 0
jump = 1 // sets jump to one so the user doesn't keep flying upwards
y2 = y // stores the current y position
yspeed = -2 // sets the yspeed to -2, makes the ball move upwards
endif
// once the user has jumped 100 pixels higher than from where it started
// bring it back down
if y <= y2 - 100 then yspeed = 2
// move the y position of the ball at the speed of yspeed
inc y, yspeed
// dont let the ball fall through the ground
if y > 400
y = 400
jump = 0 // once the ball has hit the ground, let it jump again
endif
// display instructions
text 0, 0, "Use the arrowkeys to move and space to jump"
sync // update
loop
Hope this helps
A clever person solves a problem, a wise person avoids it - Albert Einstein