Hi all,
How is life in the classic dark basic?
I made some code for a random bouncing ball.
set display mode 640,480,32
sync on
hide mouse
disable escapekey
cls
ink rgb(0,255,0),0
box 0,0,639,10
get image 2,0,0,639,10
cls
xbal=10
ybal=455
circle 10,10,5
rem or use a bitmap
` load bitmap "ball.bmp",1
get image 1,0,0,20,20
rem delete the bitmap
`delete bitmap 1
cls
repeat
if spacekey()
xbal=10
ybal=455
randomize timer()
velocity_xbal=rnd(15)+1
initial_velocity_ybal=(-1*rnd(30))-1
velocity_ybal=initial_velocity_ybal
endif
cls
text 0,0,"speed_x: "+str$(velocity_xbal)
text 0,15,"bouncing_heigt_y: "+str$(initial_velocity_ybal)
text 0,30,"speed_y: "+str$(velocity_ybal)
text 0,45,"press spacebar to start/change ball moves, press enter to quit."
xbal=xbal+velocity_xbal
if (xbal>640 or xbal<0)
velocity_xbal=-1*velocity_xbal
endif
ybal=ybal+velocity_ybal
if (-1*velocity_ybal<=initial_velocity_ybal)
velocity_ybal=(-1*velocity_ybal)
else
velocity_ybal=velocity_ybal+1
endif
sprite 1,xbal,ybal,1
sprite 2,0,470,2
sync
until returnkey()=1
delete image 1
delete image 2
end
It looks like it flickers. Is there something to do about that?
With div studio (old basic program) i could use a double buffer. I don't know if that is possible in dbc (i can't find it in the help-files)?
Greetings!
Toedeledoki