bouncing ball by Sven B2nd Jan 2005 4:32
|
---|
Summary A bouncing ball. It's not much, but maybe it can help... Description Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com `*********************************************** `Bouncing ball `*********************************************** `coded by Sven Boulanger `*********************************************** sync on : sync rate 60 hide mouse `create ball texture ink rgb(255,255,0),0 box 0,0,10,20 ink rgb(0,255,255),0 box 10,0,20,20 ink rgb(255,0,0),0 box 20,0,30,20 ink rgb(0,0,255),0 box 30,0,40,20 ink rgb(0,255,0),0 box 40,0,50,20 get image 1,0,0,50,20 `create ball make object sphere 1,5 texture object 1,1 zrotate object 1,rnd(90) position object 1,0,0,0 position camera 0,12,-25 point camera 0,12,0 `gravity --> if this is set to 0: the ball would float around(in this case: up) gravity#=0.1 `bounce --> if this value is set to 0: the ball would smash to the ground and wouldn't bounce again bounce#=0.85 `this value changes all the time but this value=the height of the first bounce yspeed#=2.0 `minimum bounce minyspeed#=0.65 do center text 320,10,str$(yspeed#) `effect on the ball height posy#=posy#+yspeed# `effect gravity yspeed#=yspeed#-gravity# `now the bounce part if posy#<object size y(1)/2 yspeed#=abs(yspeed#)*bounce# if yspeed#<minyspeed# then yspeed#=0.0 endif `update ball position object 1,0,posy#,0 sync loop |