I just decided to make a ball game and thought that I should try to discover how to make a ball bounce. The result became this little demo!
I just wanted to hear some oppinions and some tips how to make it better, although I'm pretty proud of it. The only thing I don't like is that the K#-value that I'm using to pull down the ball (object position Y(1)-K#) isn't decreasing in a way that I would like, and I haven't found a way to decrease it more and more instead of 0.4, which I'm doing now.
Anyway! Here's the demo!
(If you want to change the speed, height, and the angle of the ball, just play around with the two mousebuttons

)
Sync on
Sync rate 60
Set display mode 1024,768,32
Hide mouse
Set camera range 1,300000
Rem skapar mark
Make matrix 1,2000,2000,25,25
Position matrix 1,-1000,-25,-1000
Rem skapar en boll
Make object sphere 1,50
Position object 1,0,500,0
Rem variabler
H# = 2
FH#=1
Rem huvuddata
Do
Remstart
K# = Kraft
H# = Hastighet
Remend
Rem ändrar bollplaceringen
If mouseclick()=1 or mouseclick()=3
K#=(mousemoveY()*(-1))
If mouseclick()=1
H#=MousemoveX()
Else
H#=0
Yrotate object 1,wrapvalue(object angle Y(1)+mousemoveX())
Endif
Position object 1,object position X(1),object position Y(1)-mousemoveY(),object position Z(1)
Move object 1,H#
Rem håller bollen ovanför Y=0
If object position Y(1)<0 then Position object 1,object position X(1),1,object position Z(1)
Else
Rem studs
Dec K#,0.4
If object position Y(1)<0
Position object 1,object position X(1),object position Y(1)-K#,object position Z(1)
K#=(K#*(-1))*0.75
H#=H#*0.75
Endif
Rem placerar ut bollen
Position object 1,object position X(1),object position Y(1)+K#,object position Z(1)
Move object 1,H#
Endif
Rem ökar K#
If spacekey()=1 then inc K#,1
Rem placerar ut kamera
Position camera 1000,0,500
Point camera object position X(1),object position Y(1),object position Z(1)
Rem skriver ut saker
Set cursor 0,0
Print "Ball position; XYZ"
Print ""+str$(Object position X(1))+", "+str$(Object position Y(1))+", "+str$(Object position Z(1))
Print "Variables:"
Print "Function - Name = Value"
Print "Force - K# = "+str$(K#)
Print "Speed - H# = "+str$(H#)
Print "Framerate:"
Print screen FPS()
Sync
Loop
www.godhatessweden.com
Good laughter!