This program uses two spheres (blue and yellow). The blue sphere moves across the screen from left to right. The yellow sphere orbits the blue sphere.There is a control panel for each sphere. The blue box controls the x/y/z placement and the speed of the blue sphere. The yellow box controls the x/y/z orbit size and the
speed of the yellow sphere. There is also a BIG stick of TNT. Click it and watch the yellow sphere explode. Hope you enjoy this simple demonstration. (No graphics needed, they are coded.)
rem Demonstration of Cos and Sin
rem by Brazos 6/12/09
rem This program uses two spheres (blue and yellow). The blue sphere moves
rem across the screen from left to right. The yellow sphere orbits the blue sphere.
rem There is a control panel for each sphere. The blue box controls the x/y/z placement
rem and the speed of the blue sphere. The yellow box controls the x/y/z orbit size and the
rem speed of the yellow sphere. There is also a stick of TNT. Click it and watch the yellow
rem sphere explode. Hope you enjoy this simple demonstration.
rem INSTRUCTIONS:
rem "cx/cy/cz" controls the blue sphere's placement
rem "xmov" controls the constant movement of the blue sphere (set to "0" to stop sphere)
rem "xsiz/ysiz/zsiz" controls the x,y z distance of orbit of the yellow sphere
rem "visz" controls the orbit speed of the yellow sphere
rem "<" is down ">" is up
gosub setup
Do
gosub check_input
gosub do_math
gosub positions
gosub text_it
sync
loop
end
setup:
set display mode 800,600,32
cls 0:sync on:sync rate 60:backdrop on:color backdrop 0:autocam off
randomize timer()
randomize 256:randomize 361
rem images*****************
rem graphics for blue sphere control box
ink rgb(50,50,200),0
box 0,519,100,599
ink rgb(100,100,255),0
line 0,519,100,519
line 0,519,0,599
ink rgb(50,50,170),0
line 100,520,100,599
line 0,599,100,599
rem graphics for yellow sphere control box
ink rgb(100,100,50),0
box 132,519,232,599
ink rgb(150,150,70),0
line 132,519,132,599
line 132,519,232,519
ink rgb(70,70,50),0
line 232,520,232,599
line 232,599,232,599
rem graphics for tnt
ink rgb(200,50,50),0
box 255,539,295,599
ink rgb(160,25,25),0
line 253,539,253,599
line 297,539,297,599
ellipse 275,540,20,3
ellipse 275,540,19,2
ink rgb(180,35,35),0
line 254,539,254,599
line 296,539,296,599
ink rgb(150,150,70),0
line 275,538,283,528
line 283,528,296,530
rem lines and text in control boxes
ink 0,0
line 0,535,230,535
line 0,551,230,551
line 0,567,230,567
line 0,583,230,583
line 0,599,230,599
line 41,535,41,599
line 71,535,71,599
line 86,535,86,599
line 171,535,171,599
line 201,535,201,599
line 216,535,216,599
ink rgb(100,100,100),0
center text 51,519,"Blue Sphere"
center text 21,537,"CX"
center text 21,552,"CY"
center text 21,568,"CZ"
center text 21,584,"XMOV"
center text 87,537,"< >"
center text 87,552,"< >"
center text 87,568,"< >"
center text 87,584,"< >"
center text 276,555,"T N T"
ink rgb(150,150,150),0
center text 181,519,"Yellow Sphere"
center text 151,537,"XSIZ"
center text 151,552,"YSIZ"
center text 151,568,"ZSIZ"
center text 151,584,"VSIZ"
center text 217,537,"< >"
center text 217,552,"< >"
center text 217,568,"< >"
center text 217,584,"< >"
ink 0,0
center text 50,518,"Blue Sphere"
center text 180,518,"Yellow Sphere"
center text 20,536,"CX"
center text 20,551,"CY"
center text 20,567,"CZ"
center text 20,583,"XMOV"
center text 150,536,"XSIZ"
center text 150,551,"YSIZ"
center text 150,567,"ZSIZ"
center text 150,583,"VSIZ"
center text 86,536,"< >"
center text 86,551,"< >"
center text 86,567,"< >"
center text 86,583,"< >"
center text 216,536,"< >"
center text 216,551,"< >"
center text 216,567,"< >"
center text 216,583,"< >"
center text 275,554,"T N T"
rem grab the graphic just drawn
get image 1,0,519,298,599
rem objects********************
rem blue sphere
make object sphere 500,100
color object 500,rgb(100,100,255)
rem yellow sphere
make object sphere 501,25
color object 501,rgb(200,200,0)
rem star/explosion spheres
for t=1 to 100
make object sphere t,5
color object t,rgb(rnd(255)+100,rnd(255)+100,rnd(255)+100)
rotate object t,rnd(360),rnd(360),rnd(360)
position object t,rnd(3000)-1500,rnd(3000)-1500,rnd(100)+600
next t
rem varibles*******************
v=1:cx=-480:cy=0:cz=0:xsiz=150:ysiz=20:zsiz=100:vsiz=4:button$="move":xmov=5
rem places camera z position to -1000
position camera 0,0,-1000
return
check_input:
rem paste graphic with control boxes and tnt
paste image 1,0,519
rem variables for mouseclick and mouse x/y positions
xp=mousex():yp=mousey():mc=mouseclick()
rem controls for blue sphere placement and speed
if mc=1 and xp>71 and yp>535 and xp<85 and yp<551 then dec cx,10
if mc=1 and xp>71 and yp>551 and xp<85 and yp<567 then dec cy,10
if mc=1 and xp>71 and yp>567 and xp<85 and yp<583 then dec cz,10
if mc=1 and mke=0 and xp>71 and yp>583 and xp<85 and yp<599 then mke=1:dec xmov,1
if mc=1 and xp>86 and yp>535 and xp<101 and yp<551 then inc cx,10
if mc=1 and xp>86 and yp>551 and xp<101 and yp<567 then inc cy,10
if mc=1 and xp>86 and yp>567 and xp<101 and yp<583 then inc cz,10
if mc=1 and mke=0 and xp>86 and yp>583 and xp<101 and yp<599 then mke=1:inc xmov,1
rem controls for yellow sphere orbits and speed
if mc=1 and xp>201 and yp>535 and xp<216 and yp<551 then dec xsiz,1
if mc=1 and xp>201 and yp>551 and xp<216 and yp<567 then dec ysiz,1
if mc=1 and xp>201 and yp>567 and xp<216 and yp<583 then dec zsiz,1
if mc=1 and mke=0 and xp>201 and yp>583 and xp<216 and yp<599 then mke=1:dec vsiz,1
if mc=1 and xp>216 and yp>535 and xp<231 and yp<551 then inc xsiz,1
if mc=1 and xp>216 and yp>551 and xp<231 and yp<567 then inc ysiz,1
if mc=1 and xp>216 and yp>567 and xp<231 and yp<583 then inc zsiz,1
if mc=1 and mke=0 and xp>216 and yp>583 and xp<231 and yp<599 then mke=1:inc vsiz,1
rem if tnt is clicked this sets flag "button$" to explode
if mc=1 and xp>255 and yp>539 and xp<295 and yp<599 and mke=0 then mke=1:button$="explode"
rem if the tnt has been clicked go to explode
if button$="explode" then gosub explode
rem set limitations of blue and yellow sphere's placement and speed
if cx>999 then cx=-999
if cy>999 then cy=0
if cz>999 then cz=0
if xmov>25 then xmov=0
if cx<-999 then cx=999
if cy<-999 then cy=0
if cz<-999 then cz=0
if xmov<-25 then xmov=0
if xsiz>720 then xsiz=100
if ysiz>720 then ysiz=0
if zsiz>720 then zsiz=100
if vsiz>25 then vsiz=0
if xsiz<-720 then xsiz=100
if ysiz<-720 then ysiz=0
if zsiz<-720 then zsiz=100
if vsiz<-25 then vsiz=0
rem flag for single clicking on blue and yellow sphere's speed
if mc=0 and mke=1 then mke=0
return
do_math:
rem gets coordinates for yellow sphere and moves blue sphere
v=v+vsiz
ox=cos(v)*xsiz
oy=sin(v)*ysiz
oz=sin(v)*zsiz
cx=cx+xmov
rem resets blue sphere to left side of screen when it goes off right side
rem resets placement of blue sphere
rem resets coordinates for yellow sphere
rem resets placement of star/explosion spheres
if cx=>998
cx=-999
cy=rnd(250)-125
cz=rnd(100)-200
xsiz=rnd(150)+50
ysiz=rnd(25)+25
zsiz=rnd(150)+50
vsiz=rnd(9)+1
ran=rnd(5)+1
if ran=1 then xsiz=xsiz-(xsiz*2)
if ran=2 then ysiz=ysiz-(ysiz*2)
if ran=3 then zsiz=zsiz-(zsiz*2)
for t=1 to 100
position object t,rnd(3000)-1500,rnd(3000)-1500,rnd(100)+600
next t
endif
return
positions:
rem placement of blue and yellow sphere
position object 500,cx,cy,cz
show object 501
position object 501, cx+ox,cy+oy,cz+oz
rem changes color on star/explosion spheres
for t=1 to 100
color object t,rgb(rnd(255),rnd(255),rnd(255))
next t
return
explode:
rem get substitute image of control panel to be pasted during explosion
rem so there will be no disappearance or disruption of the panel
gosub text_it
sync
get image 2,0,519,298,599
rem place all star/explosion spheres at yellow sphere's position
for t=1 to 100
position object t, cx+ox,cy+oy,cz+oz
next t
rem hide yellow sphere
hide object 501
rem clears screen white/red/black
rem moves blue sphere off right side of screen
rem moves the star/explode spheres into a spreading motion
rem after explosion, resets star/explosion spheres to star positions
rem resets blue sphere's position and movement
for time=1 to 350
if time=5 or time=10
cls rgb(255,255,255)
sync
sleep 20
cls rgb(255,0,0)
sync
sleep 10
cls 0
sync
endif
xmov=12
cx=cx+xmov
if cx+xmov>999 then xmov=0
position object 500,cx,cy,cz
for t=1 to 100
move object t,5
if time>100 then color object t,rgb(rnd(255),rnd(255),rnd(255))
if time=300 then position object t, cx+ox,cy+oy,cz+oz
next t
paste image 2,0,519
sync
next time
cx=999
xmov=5
button$="move"
gosub do_math
return
text_it:
rem texts all the variables to screen
ink 0,0
center text 56,536,str$(cx)
center text 56,551,str$(cy)
center text 56,567,str$(cz)
center text 56,583,str$(xmov)
center text 186,536,str$(xsiz)
center text 186,551,str$(ysiz)
center text 186,567,str$(zsiz)
center text 186,583,str$(vsiz)
return
end