Okay, I made up something based off of your code that works.
sync on : sync rate 60
randomize timer() : hide mouse
`Declare variables
True = 1 : False = 0 : Gravity = 1 : JumpSpeed = -5 : FallLimit = 5 : YSpeed = 0 : XSpeed = 6
XPosition = 0 : YPosition = 520 : OnGround = False : Jumping = 0
ScrWid = screen width() : ScrHgt = screen height() : player = 2
` make some images
ink rgb(0,255,0),0
box 0,0,ScrWid,50
get image 1,0,0,ScrWid,50
cls rgb(255,0,0)
get image 2,0,0,48,48
cls rgb(200,0,200)
get image 3,0,0,48,48
cls
sprite 1,0,ScrHgt - 50,1
sprite player,ScrWid/2,ScrHgt - 98,2
sprite 3,rnd(500) + 200,ScrHgt - 180,3
`Main loop
do
oldX = sprite x(2) : oldY = sprite y(2)
`Mirror player
if leftkey()=1
if Mirrored=0
Mirrored=1 : mirror sprite 2
endif
if XPosition > XSpeed then dec XPosition,XSpeed
endif
if rightkey()=1
if Mirrored=1
Mirrored=0 : mirror sprite 2
endif
if XPosition < (ScrWid - 48) then inc XPosition,XSpeed
endif
`INC XPosition, (RIGHTKEY() - LEFTKEY()) * 3
IF Jumping > 0
YSpeed = JumpSpeed
OnGround = False
inc YPosition, YSpeed
dec Jumping
ENDIF
if Jumping = false
if OnGround = true
JumpKey = SPACEKEY()
if Jumpkey = true
Jumping = 10
endif
endif
endif
SPRITE 2,XPosition,YPosition,2
collide = SPRITE collision (2,0)
if collide = false and Jumping = false
if YSpeed < FallLimit then INC YSpeed, Gravity
inc YPosition, YSpeed
endif
if collide = 1
if OnGround = true
YPosition = oldY
ELSE
OnGround = true
XPosition = oldX : YPosition = oldY
YSpeed = 0
ENDIF
ENDIF
if collide = 3 : ` hit overhead block
XPosition = oldX : YPosition = oldY
Jumping = false : YSpeed = gravity
if OnGround = false then inc YPosition, gravity
endif
SPRITE 2,XPosition,YPosition,2
if returnkey() = true then exit
SYNC
loop
end
I made some images in the code and created sprites with them. You can move the red box around and use the spacebar to jump. When it collides with the overhead sprite, it puts the player back where they were. The return key exits. I also added manual SYNCing, as the player flew off the screen immediately.
Your gravity and YSpeed variables were floats, which is used for 3D positioning, not 2D sprites. Anyway, I changed them.
You can look at the code to see how it works. I hope this is helpful.