Help with jump platform code please!!

Blitz3D Forums/Blitz3D Beginners Area/Help with jump platform code please!!

; My first Steps into Solo programming
; using Blitz 3D !!
;
; By Paul Harthen (aka Spectre)
; 14 - 3 - 2004 (C)

Const screenx=800 
Const screeny=600

Graphics screenx,screeny,16,2

SetBuffer BackBuffer()
player=LoadImage("alien.bmp")

Type aliens
	Field char
	Field x
	Field y
	Field speed
	Field jump_height
	Field jump_width
	Field jump_angle
End Type

alien.aliens=New aliens
alien\char=player
alien\x=screenx/2
alien\y=screeny/2
alien\speed=2
alien\jump_height=100
alien\jump_width=90
alien\jump_angle=0

char=alien\char
charx=alien\x
chary=alien\y
charspeed=alien\speed
height=alien\jump_height
width=alien\jump_width
charangle=alien\jump_angle


direction=0

While Not KeyHit(1)
	Cls
	
	If KeyDown(203)  
		charx=charx-charspeed
		direction=-1
	EndIf
	
	If KeyDown(205)  
		charx=charx+charspeed
		direction=1
	EndIf
	
	If KeyDown(57)
		Gosub jump
	EndIf
	
	If charx<0 Then charx=0
	If charx>screenx-ImageWidth(char) Then charx=screenx-ImageWidth(char)
	
	DrawImage char,charx,chary
	Flip
Wend

For alien.aliens=Each aliens
	Delete alien
Next

End

.Jump
If charangle < 181

   If direction=-1
      x=Cos(charangle)*width/2
      charx=xoffset+x-width/2
   EndIf
   If direction=1
      x=-Cos(charangle)*width/2
      charx=xoffset+x+width/2
   EndIf

   y=Sin(charangle)*height/2

   chary=yoffset+y
   charangle=charangle+charspeed

Else

   chary=yoffset
   charangle=0

EndIf
Return


Can anyone help with this code I am working on please!!???

What I am trying to do is get this sprite to move left and right and jump when you press the space bar!!

I have really messed up somewhere!!

Also if you could explain or change the jump routine to a function, that would be great as I couldn't do it!! :)

Another thing....... Am I doing the Type thing correct as it is hard to understand!!! :)))

Thanks if you can help.