So i started working with GLbasic today and experimented a bit and felt a bit too proud about my first project.
I decided to upload it and here it is.
a quick and simple script For gravity and jumping. Wich is also my absolutely first project.
Spacebar to jump! ^^
And holding down the ctrl will make you bounce. =D
GOSUB Init
main:
GOSUB MoveAll
GOSUB ShowAll
GOTO main
SUB Init:
GLOBAL player_x = 450
GLOBAL player_y = 450
GLOBAL lifts = 0
GLOBAL gforce = 0
LOADSPRITE "ball.bmp" ,0
ENDSUB
SUB MoveAll:
IF KEY(57) AND lifts=0 THEN lifts=50
IF lifts>0
player_y=player_y-0.8*SQR(lifts)
lifts=lifts-1
ENDIF
IF player_y<450
player_y=player_y+gforce
gforce=gforce+0.2
ENDIF
IF player_y<450=FALSE
gforce=0
IF KEY(29)=FALSE THEN lifts=0
ENDIF
ENDSUB
SUB ShowAll:
DRAWSPRITE 0, player_x, player_y
SHOWSCREEN
ENDSUB
Notice tought that i am using a sprite called ball.bmp
Nothing wrong with being proud of something relatively simple! After all, now you have this routine in place, it wouldn't take much of a leap of faith to think about converting it into the start of a platform game ....
haha thanks! =D