Main Menu

bounce ball

Started by ATLUS, September 23, 2009, 03:14:54 AM

Previous topic - Next topic

ATLUS

ver.001  :)

PlayBASIC Code: [Select]
setfps 60
y#=100
spd#=0
grav#=9.8
top#=4.57
f=0
verspd#=2
do
cls rgb(0,0,0)
y#=y#+grav#+spd#

if y#>550
f=1
spd#=-30
endif

if f=1
if spd#<30
y#=y#+spd#
spd#=spd#+verspd#
if spd#>30
spd#=spd#-verspd#
f=0
endif
endif
endif



circle 400,y#,20,1
line 0,550,800,550
text 10,10,spd#
sync
loop





micky4fun

Hi ATLUS

this does not seem to work properly as ball hits floor at different points , setfps to 10 and you will see what i meen

mick :)

ATLUS

Hi Mick
oh Right, thanks!!! i fix this in next version ;)

ATLUS

ver.002    spaghetti code  :-[

setfps 60
y#=100
spd#=0
grav#=9.8
top#=4.57
f=0
verspd#=2
outspd#=-25
length#=0
do
cls rgb(0,0,0)
y#=y#+grav#+spd#
if f=0
spd#=spd#+0.1
if spd#>=14 then spd#=14
endif

if y#>=550
f=1
length#=spd#*4
spd#=0
endif

if f=1
if length#>=0
y#=y#+outspd#
length#=length#-1
endif
endif

if length#<1
f=0
endif


circle 400,y#,20,1
line 0,570,800,570
text 10,10,"Length "+str$(length#)
text 10,20,"Spd "+str$(spd#)
text 10,30,f
text 10,40,"y "+str$(y#)
sync
loop

Error Missing Closing Square Bracket

stef


Hi!

Another bounce ball  :)

Greetings
stef



setfps 60
y#=100
spd#=0
grav#=9.8
f1#=0.95
f2#=0.2

do
cls rgb(0,0,0)

spd#=spd#+grav#*f2#
y#=y#+spd#

if y#>=550
y#=550
spd#=-spd#*f1#
endif

circle 440,y#,20,1
line 0,570,800,570

sync
loop



micky4fun

Hi All

well another one here , but the ending needs a little work , maybe someone can stop ball from doing what it does once stuck on line

setfps 30
constant gravity# = 0.25
global box_x# = 100.0
global box_y# = 100.0
global box_velocity_x# = 0.0
global box_velocity_y# = 0.0

do
cls 0
     line 0,565,800,565
     if box_y#>550
box_velocity_y# = -box_velocity_y#
r# = 65 - box_y#
box_y# = 65 - r#
endif
     Update_Box()
     circle box_x#,box_y#,10,1
sync
loop

function Update_Box()
box_velocity_y# = box_velocity_y# + gravity#
box_y# = box_y# + box_velocity_y#
box_x# = box_x# + box_velocity_x#
endfunction


mick  :)

ATLUS

Wow Great stef!!! Thanks for code!!!

Mick, if set fps 60 and wait 2-3 minits you ball move out in line ;)

ATLUS

is Stef ver. but using sinRadius function
setfps 60
y#=100
spd#=0
grav#=9.8
f1#=0.8
f2#=0.2

do
cls rgb(0,0,0)

spd#=spd#+grav#*f2#
y#=y#+SinRadius(14,spd#)


if y#>=550
y#=550
spd#=-spd#*f1#
endif

circle 440,y#,20,1
line 0,570,800,570
text 10,10,spd#

sync
loop

micky4fun

Hi ATLUS

yep think you have nailed it with Stef version using sinRadius

yep mine do do funny things once ball got stuck on line
Quotebut the ending needs a little work

mick :)