This is a copy of an old post I did some time ago on this very subject. It contains the source code, but no sprite images. Sorry, you will have to study the code and design the sprites yourself to work with it. It uses trig functions to make the sprite jump. The code was originally designed to work at the bottom of the screen. This is perfect for those wanting to make a 2D fighter game, but with a little work, it could be used on a Mario style game.
-----------------------------------------------------------------------
You say your having trouble with making a sprite jump. My character control subroutine I wrote handles this. It uses a little bit of trig. to calculate the arc for the jump. The code doesn't do collision with the background or use gravity, but it could employ this with a little modification. I condensed the code below.
character_jump:
Rem Poll Keyboard Controls Only if Character Is Not Jumping
if jump=0
character_action=2
if controlkey()=1 and rightkey()=1 then character_action=0
if controlkey()=1 and leftkey()=1 then character_action=1
endif
select character_action
Rem Jump Right
case 0
if jump=0 then jump=1:frame=15:a=270:sx=sprite x(1)
if aflag=2 then aflag=1:mirror sprite 1
x=(sx+150)+150*sin(a):y=512+125*cos(a)
dec a,10:if a<90 then jump=0
endcase
Rem Jump Left
case 1
if jump=0 then jump=1:frame=15:a=90:sx=sprite x(1)
if aflag=1 then aflag=2:mirror sprite 1
x=(sx-150)+150*sin(a):y=512+125*cos(a)
inc a,10:if a>270 then jump=0
endcase
endselect
Rem Check Character Limits
if x<0 then x=0
if x>832 then x=832
if y>512 then y=512
endif
Rem Update Character Position And Animation
sprite 1,x,y,frame
return
This code works with a 192x256 sprite on a 1024x768 screen. In order to use the subroutine with different sprite and screen resolutions you will have to modify the X and Y character limits.
To calculate the limits use:
X max. = SCREEN WIDTH()-SPRITE WIDTH(SpriteNumber)
Y max. = SCREEN HEIGHT()-SPRITE HEIGHT(SpriteNumber)
As I said before, the routines uses trig. to create a jumping arc for the character. Here is the breakdown:
x=(sx+150)+150*sin(a):y=512+125*cos(a) jumping right
x=(sx-150)+150*sin(a):y=512+125*cos(a) jumping left
variables usage:
sx = current location of sprite at the start of the jump.
a = angle in degrees from center of arc.
150 = x eliptical value (radius) and offset for x.
125 = y eliptical value (radius) for y.
512 = center of arc at y and current character position at y.
This code is designed to work at the bottom of the screen. Play with the code and change some of the values to see how it works. Try to make it work all over the screen on the Y axis...