This is for DBC. I am a newbie. When I have difficulty understanding a command I like to create a program that puts the command to the test. In doing so I learn each aspect of the command. I have wrote such a program for the "set object" command. I hope it will help others as it has helped me. There are other commands and "tricks" included in the program. A little "eye candy" makes programing and learning more enjoyable. You will need only one image (included). Be sure and put the image in the same folder in which the program is saved. Hope you enjoy it.
remstart
Images:
1= orb
2= boxes following orbiting sphere
3= window
4= cover up panel for backdrop being off
24 to 33=boxes popping up and moving away
Objects:
1= plain
2= orbiting sphere
3 to 23= boxes following orbiting sphere (gives it that bumpy look)
24 to 33=small boxes popping up and moving away
40= big box
41= big sphere
remend
gosub set_up_stuff
do
if bacdrp$="Backdrop off" then paste image 4,0,0
gosub check_keys
gosub do_the_math
gosub write_it
gosub make_changes
sync
loop
end
rem ***************************************************************************************
check_keys:
if inkey$()="a" then wf=0:scr$=script$(1)
if inkey$()="q" then wf=1:scr$=script$(1)
if inkey$()="s" then tr=0:scr$=script$(2)
if inkey$()="w" then tr=1:scr$=script$(2)
if inkey$()="d" then cul=0:scr$=script$(3)
if inkey$()="e" then cul=1:scr$=script$(3)
if inkey$()="f" then fil=0:scr$=script$(4)
if inkey$()="r" then fil=1:scr$=script$(4)
if inkey$()="g" then lt=0:scr$=script$(5)
if inkey$()="t" then lt=1:scr$=script$(5)
if inkey$()="h" then fo=0:scr$=script$(6)
if inkey$()="y" then fo=1:scr$=script$(6)
if inkey$()="j" then am=0:scr$=script$(7)
if inkey$()="u" then am=1:scr$=script$(7)
if inkey$()="5" then inc al,1:scr$=script$(8)
if inkey$()="2" then dec al,1:scr$=script$(9)
if inkey$()="1" then inc fd,10:scr$=script$(10)
if inkey$()="0" then dec fd,10:scr$=script$(11)
if inkey$()="z" then objmode$="plain":scr$=script$(12)
if inkey$()="x" then objmode$="box":scr$=script$(13)
if inkey$()="c" then objmode$="sphere":scr$=script$(14)
if inkey$()="v"
texture object 1,1
texture object 40,1
texture object 41,1
texmode$="orb"
scr$=script$(15)
endif
if inkey$()="b"
texture object 1,3
texture object 40,3
texture object 41,3
texmode$="window"
scr$=script$(16)
endif
if inkey$()="3"
anud#=0
position camera 0,0,-200
inout$="outside"
scr$=script$(17)
endif
if inkey$()="6" then inout$="closer":scr$=script$(18)
if inkey$()="9" then inout$="inside":scr$=script$(19)
if inout$="closer" and objmode$="plain" then position camera 0,0,-100
if inout$="closer" and objmode$="box" then position camera 0,0,-50
if inout$="closer" and objmode$="sphere" then position camera 0,0,-100
if inout$="inside" and objmode$="plain" then position camera 0,0,-20
if inout$="inside" and objmode$="box" then position camera 0,0,-34
if inout$="inside" and objmode$="sphere" then position camera 0,0,-48
if downkey()=1 then inc any#,0.5:scr$=script$(20)
if upkey()=1 then dec any#,0.5:scr$=script$(21)
if shiftkey()=1
backdrop on
bacdrp$="Backdrop on"
scr$=script$(22)
endif
if controlkey()=1
backdrop off
bacdrp$="Backdrop off"
scr$=script$(23)
endif
return
rem ************************************************************************************************
do_the_math:
if anx#>360 then anx#=0
if anx#<0 then anx#=360
if any#>360 then any#=0
if any#<0 then any#=360
inc yobj
if yobj>360 then yobj=0
if al>100 then al=100
if al<0 then al=0
if inkey$()="" and ke=1 then ke=0
return
rem *************************************************************************************************
write_it:
ink rgb(200,200,200),0
text 0,0,scr$
text 0,205, "The line above discribes what happens."
text 0,220, "Use the keyboard to make changes below:"
text 0,235, "Wireframe (a/q):"+str$(wf)
text 0,250, "Transparency (s/w):"+str$(tr)
text 0,265, "Cull (d/e):"+str$(cul)
text 0,280, "Filter (f/r):"+str$(fil)
text 0,295, "Light (g/t):"+str$(lt)
text 0,310, "Fog (h/y):"+str$(fo)
text 0,325, "Ambient (j/u):"+str$(am)
text 0,340, "Example of command: set object 20,"+str$(wf)+","+str$(tr)+","+str$(cul)+","+str$(fil)+","+str$(lt)+","+str$(fo)+","+str$(am)
text 0,370, "Turn backdrop on/off (shiftkey/controlkey):"+bacdrp$
text 0,385, "Adjust ambient light (2/5):"+str$(al)
text 0,400, "Adjust fog distance (1/0):"+str$(fd)
text 0,415, "Change objects: 'z'=plain/ 'x'=box/ 'c'=sphere: "+objmode$
text 0,430, "Change the texture of the object (v/b): "+texmode$
text 0,445, "Change location of camera to outside, closer or inside of object (3/6/9): "+inout$
text 0,460, "Tilt camera up/down (upkey/downdown): "+str$(any#)
return
rem ********************************************************************************************
make_changes:
set object 1,wf,tr,cul,fil,lt,fo,am
set object 40,wf,tr,cul,fil,lt,fo,am
set object 41,wf,tr,cul,fil,lt,fo,am
set ambient light al
fog distance fd
if objmode$="plain"
show object 1
hide object 40
hide object 41
endif
if objmode$="box"
show object 40
hide object 1
hide object 41
endif
if objmode$="sphere"
show object 41
hide object 1
hide object 40
endif
rotate object 1,0,yobj,5
rotate object 40,0,yobj,5
rotate object 41,0,yobj,5
rotate camera any#,0,0
rem adjusting the orbiting sphere
v=v+1
if v>360
cyran=rnd(50)-25
czran=rnd(100)+80:v=0
endif
ox=cos(v)*80
oy=sin(v)*cyran
oz=sin(v)*czran
inc tbox
for t=2 to 23
position object t,ox,oy,oz
if t>2 and tbox>15
rotate object t,rnd(360),rnd(360),rnd(360)
if t=23 then tbox=0
endif
next t
rem adjusting pop-up boxes (moving and re-texturing them)
for t=24 to 33
move object t,1
for t1=1 to 3
bpos(t-23,t1)=object position x(t)
if bpos(t-23,t1)>150 or bpos(t-23,t1)<-150
position object t,0,0,0
set current bitmap 1
ink rgb(rnd(255)+200,rnd(255)+200,rnd(255)+200),0
box 0,0,49,49
for t2=1 to 200
ink rgb(rnd(255)+150,rnd(255)+150,rnd(255)+150),0
dot rnd(50),rnd(50)
next t2
get image t,0,0,49,49
cls 0
set current bitmap 0
pic(t-23)=t
texture object t,pic(t-23)
rotate object t,rnd(360),rnd(360),rnd(360)
endif
next t1
next t
return
rem *****************************************************************************************************
set_up_stuff:
randomize timer():cls 0:sync on:autocam off:backdrop on:color backdrop 0
dim bpos(10,3)
dim pic(10)
dim script$(23)
fog on:fog distance 800:fog color 0
set ambient light 60
set text font "ariel"
set text size 16
rem loading discriptions of keys being pressed from data
for t=1 to 23
read A$
script$(t)=A$
next t
rem trashed-out satellite graphic
load image "orb.bmp",1
rem make texture for boxes that are inside and following orbiting sphere
create bitmap 1,639,479
ink rgb(100,100,120),0
box 0,0,49,49
for t=1 to 200
ink rgb(rnd(255)+200,rnd(255)+200,rnd(255)+200),0
dot rnd(50),rnd(50)
next t
get image 2,0,0,49,49
cls 0
rem make the window texture for plain, box and sphere
rem (I know...I know....it's overdone for an example, but I like graphics
ink rgb(100,100,100),0
box 0,0,254,254
for t=1 to 100
ink rgb(90,90,90),0
dot rnd(254),rnd(254)
ink rgb(50,50,50),0
dot rnd(254),rnd(254)
ink rgb(80,80,80),0
dot rnd(254),rnd(254)
next t
ink rgb(125,125,125),0
box 4,108,108,148
box 144,104,254,152
box 44,44,84,84
box 174,44,214,84
box 44,174,84,214
box 174,174,214,214
ink rgb(100,100,100),0
box 6,110,106,146
box 150,110,248,146
box 48,48,80,80
box 178,48,210,80
box 48,178,80,210
box 178,178,210,210
ink 0,0
box 8,112,104,144
box 152,112,246,144
box 54,54,74,74
box 184,54,204,74
box 54,184,74,204
box 184,184,204,204
for hr=10 to 16
circle 64,64,hr
circle 194,64,hr
circle 64,194,hr
circle 194,194,hr
if hr=13 then ink rgb(70,70,70),0
if hr>15 then ink rgb(120,120,100),0
next hr
get image 3,0,0,254,254
cls 0
ink rgb(100,255,100),0
box 0,0,10,7
ink rgb(255,100,100),0
box 0,8,10,15
cls 0
get image 10,0,0,10,15
rem get black image for cover up when backdrop is off
get image 4,0,0,639,16
set current bitmap 0
rem the main plain, box and sphere
make object plain 1,100,100
texture object 1,3
position object 1,0,0,0
make object box 40,70,70,70
texture object 40,3
position object 40,0,0,0
hide object 40
make object sphere 41,100
texture object 41,3
position object 41,0,0,0
hide object 41
rem orbiting bumpy sphere
make object sphere 2,25
color object 2,rgb(100,100,120)
position object 2,50,-30,100
rem boxes inside and following orbiting sphere
for t=3 to 23
make object box t,16,16,16
rotate object t,rnd(360),rnd(360),rnd(360)
texture object t,2
next t
rem small pop-up boxes that float away
for t=24 to 33
make object box t,5,5,5
set object t,1,0,0
position object t,0,0,0
texture object t,2
rotate object t,rnd(360),rnd(360),rnd(360)
next t
position camera 0,0,-200
wf=1:tr=0:cul=0:fil=1:lt=1:fo=1:am=1:fd=800:al=60:any#=0.0:objmode$="plain":texmode$="window":inout$="outside"
bacdrp$="on":scr$=script$(12):cyran=rnd(50)-25:czran=rnd(100)+80
return
data "When set to 0, the object shows it's wireframe. When set to 1,the object is solid."
data "When set to 0, all parts of the object colored black are transparent. When set to 1, black is solid."
data "When set to 0, the backside of the object is visible. When set to 1, it is not visible."
data "When set to 0, the texture is not effected. When set to 1, it softens (blurs) the texture."
data "When set to 0, the object will not be effected by light changes. When set to 1 light will have effect on object."
data " When set to 0, fog does not effect object. When set to 1, fog will have an effect on object."
data "When set to 0, object is not effected by ambient light. When set to 1, object is effected by ambient light."
data "The ambient light is being increased."
data "The ambient light is being decreased."
data "The fog is moving away."
data "The fog is moving closer."
data "The plain object is showing. The box and sphere are hidden."
data "The box object is showing. The plain and sphere are hidden."
data "The sphere object is showing. The plain and box are hidden."
data "The plain, box and sphere are textured with the orb texture (image 1)."
data "The plain, box and sphere are textured with the window texture (image 3)."
data "The camera is placed at the most extreme distance from the scene."
data "The camera is placed at the midway distance from the scene."
data "The camera is placed inside the center object."
data "The camera is being tilted down."
data "The camera is being tilted up."
data "The backdrop is on and objects will not leave trails as they move."
data "The backdrop is off and objects will leave a trail as they move.(cool huh?)"
I made a few changes:
gosub set_up_stuff
do
if bacdrp$="Backdrop off" then paste image 4,0,0
gosub check_keys
gosub do_the_math
gosub write_it
gosub make_changes
sync
loop
end
rem ***************************************************************************************
check_keys:
if inkey$()="a" then wf=0:scr$=script$(1):flg$=flag$(1)
if inkey$()="q" then wf=1:scr$=script$(1):flg$=flag$(1)
if inkey$()="s" then tr=0:scr$=script$(2):flg$=flag$(2)
if inkey$()="w" then tr=1:scr$=script$(2):flg$=flag$(2)
if inkey$()="d" then cul=0:scr$=script$(3):flg$=flag$(3)
if inkey$()="e" then cul=1:scr$=script$(3):flg$=flag$(3)
if inkey$()="f" then fil=0:scr$=script$(4):flg$=flag$(4)
if inkey$()="r" then fil=1:scr$=script$(4):flg$=flag$(4)
if inkey$()="g" then lt=0:scr$=script$(5):flg$=flag$(5)
if inkey$()="t" then lt=1:scr$=script$(5):flg$=flag$(5)
if inkey$()="h" then fo=0:scr$=script$(6):flg$=flag$(6)
if inkey$()="y" then fo=1:scr$=script$(6):flg$=flag$(6)
if inkey$()="j" then am=0:scr$=script$(7):flg$=flag$(7)
if inkey$()="u" then am=1:scr$=script$(7):flg$=flag$(7)
if inkey$()="5" then inc al,1:scr$=script$(8):flg$=flag$(8)
if inkey$()="2" then dec al,1:scr$=script$(9):flg$=flag$(8)
if inkey$()="1" then inc fd,10:scr$=script$(10):flg$=flag$(9)
if inkey$()="0" then dec fd,10:scr$=script$(11):flg$=flag$(9)
if inkey$()="z" then objmode$="plain":scr$=script$(12):flg$=flag$(10)
if inkey$()="x" then objmode$="box":scr$=script$(13):flg$=flag$(10)
if inkey$()="c" then objmode$="sphere":scr$=script$(14):flg$=flag$(10)
if inkey$()="v"
texture object 1,1
texture object 40,1
texture object 41,1
texmode$="orb"
scr$=script$(15)
flg$=flag$(11)
endif
if inkey$()="b"
texture object 1,3
texture object 40,3
texture object 41,3
texmode$="window"
scr$=script$(16)
flg$=flag$(11)
endif
if inkey$()="3"
any#=0
position camera 0,0,-200
inout$="outside"
scr$=script$(17)
flg$=flag$(12)
endif
if inkey$()="6" then inout$="closer":any#=0:scr$=script$(18):flg$=flag$(12)
if inkey$()="9" then inout$="inside":any#=0:scr$=script$(19):flg$=flag$(12)
if inout$="closer" and objmode$="plain" then position camera 0,0,-100
if inout$="closer" and objmode$="box" then position camera 0,0,-70
if inout$="closer" and objmode$="sphere" then position camera 0,0,-100
if inout$="inside" and objmode$="plain" then position camera 0,0,-20
if inout$="inside" and objmode$="box" then position camera 0,0,-34
if inout$="inside" and objmode$="sphere" then position camera 0,0,-48
if downkey()=1 then inc any#,0.5:scr$=script$(20):flg$=flag$(13)
if upkey()=1 then dec any#,0.5:scr$=script$(21):flg$=flag$(13)
if shiftkey()=1
backdrop on
bacdrp$="Backdrop on"
scr$=script$(22)
flg$=flag$(14)
endif
if controlkey()=1
backdrop off
bacdrp$="Backdrop off"
scr$=script$(23)
flg$=flag$(14)
endif
if leftkey()=1 then tco=0
if rightkey()=1 then tco=150
return
rem ************************************************************************************************
do_the_math:
if any#>360 then any#=0
if any#<0 then any#=360
inc yobj
if yobj>360 then yobj=0
if al>100 then al=100
if al<0 then al=0
if inkey$()="" and ke=1 then ke=0
return
rem *************************************************************************************************
write_it:
ink rgb(tco,tco,tco),0
text 0,0,flg$
text 0,16,scr$
text 0,205, "The lines above discribes what happens."
text 0,220, "Use the keyboard to make changes below:"
text 0,235, "Wireframe (a/q):"+str$(wf)
text 0,250, "Transparency (s/w):"+str$(tr)
text 0,265, "Cull (d/e):"+str$(cul)
text 0,280, "Filter (f/r):"+str$(fil)
text 0,295, "Light (g/t):"+str$(lt)
text 0,310, "Fog (h/y):"+str$(fo)
text 0,325, "Ambient (j/u):"+str$(am)
text 0,340, "Example of command: set object 20,"+str$(wf)+","+str$(tr)+","+str$(cul)+","+str$(fil)+","+str$(lt)+","+str$(fo)+","+str$(am)
text 0,370, "Turn backdrop on/off (shiftkey/controlkey):"+bacdrp$
text 0,385, "Adjust ambient light (2/5):"+str$(al)
text 0,400, "Adjust fog distance (1/0):"+str$(fd)
text 0,415, "Change objects: 'z'=plain/ 'x'=box/ 'c'=sphere: "+objmode$
text 0,430, "Change the texture of the object (v/b): "+texmode$
text 0,445, "Change location of camera to outside, closer or inside of object (3/6/9): "+inout$
text 0,460, "Tilt camera up/down (upkey/downdown): "+str$(any#)+" Toggle text color (left/right)"
return
rem ********************************************************************************************
make_changes:
set object 1,wf,tr,cul,fil,lt,fo,am
set object 40,wf,tr,cul,fil,lt,fo,am
set object 41,wf,tr,cul,fil,lt,fo,am
set ambient light al
fog distance fd
if objmode$="plain"
show object 1
hide object 40
hide object 41
endif
if objmode$="box"
show object 40
hide object 1
hide object 41
endif
if objmode$="sphere"
show object 41
hide object 1
hide object 40
endif
rotate object 1,0,yobj,5
rotate object 40,0,yobj,5
rotate object 41,0,yobj,5
rotate camera any#,0,0
rem adjusting the orbiting sphere
v=v+1
if v>360
cyran=rnd(50)-25
czran=rnd(100)+80:v=0
endif
ox=cos(v)*80
oy=sin(v)*cyran
oz=sin(v)*czran
inc tbox
for t=2 to 23
position object t,ox,oy,oz
if t>2 and tbox>15
rotate object t,rnd(360),rnd(360),rnd(360)
if t=23 then tbox=0
endif
next t
rem adjusting pop-up boxes (moving and re-texturing them)
for t=24 to 33
move object t,1
for t1=1 to 3
bpos(t-23,t1)=object position x(t)
if bpos(t-23,t1)>150 or bpos(t-23,t1)<-150
position object t,0,0,0
set current bitmap 1
ink rgb(rnd(255)+200,rnd(255)+200,rnd(255)+200),0
box 0,0,49,49
for t2=1 to 200
ink rgb(rnd(255)+150,rnd(255)+150,rnd(255)+150),0
dot rnd(50),rnd(50)
next t2
get image t,0,0,49,49
cls 0
set current bitmap 0
pic(t-23)=t
texture object t,pic(t-23)
rotate object t,rnd(360),rnd(360),rnd(360)
endif
next t1
next t
return
rem *****************************************************************************************************
set_up_stuff:
randomize timer():cls 0:sync on:autocam off:backdrop on:color backdrop 0:hide mouse
dim bpos(10,3)
dim pic(10)
dim script$(23)
dim flag$(14)
fog on:fog distance 800:fog color 0
set ambient light 60
set text font "ariel"
set text size 16
rem loading discriptions of keys being pressed from data
for t=1 to 23
read A$
script$(t)=A$
next t
for t=1 to 14
read A$
flag$(t)=A$
next t
rem trashed-out satellite graphic
load image "orb.bmp",1
rem make texture for boxes that are inside and following orbiting sphere
create bitmap 1,639,479
ink rgb(100,100,120),0
box 0,0,49,49
for t=1 to 200
ink rgb(rnd(255)+200,rnd(255)+200,rnd(255)+200),0
dot rnd(50),rnd(50)
next t
get image 2,0,0,49,49
cls 0
rem make the window texture for plain, box and sphere
ink rgb(100,100,100),0
box 0,0,254,254
for t=1 to 200
ink rgb(90,90,90),0
dot rnd(254),rnd(254)
ink rgb(50,50,50),0
dot rnd(254),rnd(254)
ink rgb(80,80,80),0
dot rnd(254),rnd(254)
next t
bb=150:cb=110:xb=148:yb=100:xb2=234:yb2=150
for t=1 to 10
ink rgb(cb,cb,bb),0
box xb,yb,xb2,yb2
inc xb:inc yb:dec xb2:dec yb2:dec cb,10:dec bb,10
next t
ink 0,0:box xb,yb,xb2,yb2
bb=150:cb=110:xb=20:yb=100:xb2=108:yb2=150
for t=1 to 10
ink rgb(cb,cb,bb),0
box xb,yb,xb2,yb2
inc xb:inc yb:dec xb2:dec yb2:dec cb,10:dec bb,10
next t
ink 0,0:box xb,yb,xb2,yb2
ink 0,0
box 56,56,72,72
box 186,56,202,72
box 56,186,72,202
box 186,186,202,202
bb=50:cb=10
for hr=10 to 21
ink rgb(cb,cb,bb),0
circle 64,64,hr
circle 194,64,hr
circle 64,194,hr
circle 194,194,hr
inc cb,10:inc bb,10
next hr
ink rgb(50,255,50),0
center text 124,151,"ABANDONED SATELLITE"
get image 3,0,0,254,254
cls 0
rem get black image for cover up when backdrop is off
get image 4,0,0,639,32
set current bitmap 0
rem the main plain, box and sphere
make object plain 1,100,100
texture object 1,3
position object 1,0,0,0
make object box 40,70,70,70
texture object 40,3
position object 40,0,0,0
hide object 40
make object sphere 41,100
texture object 41,3
position object 41,0,0,0
hide object 41
rem orbiting bumpy sphere
make object sphere 2,25
color object 2,rgb(100,100,120)
position object 2,50,-30,100
rem boxes inside and following orbiting sphere
for t=3 to 23
make object box t,16,16,16
rotate object t,rnd(360),rnd(360),rnd(360)
texture object t,2
next t
rem small pop-up boxes that float away
for t=24 to 33
make object box t,5,5,5
set object t,1,0,0
position object t,0,0,0
texture object t,2
rotate object t,rnd(360),rnd(360),rnd(360)
next t
position camera 0,0,-200
wf=1:tr=0:cul=0:fil=1:lt=1:fo=1:am=1:fd=800:al=60:any#=0.0:objmode$="plain":texmode$="window":inout$="outside"
bacdrp$="on":scr$=script$(12):flg$=flag$(10):cyran=rnd(50)-25:czran=rnd(100)+80:tco=150
return
data "When set to 0, the object shows it's wireframe. When set to 1,the object is solid."
data "When set to 0, all parts of the object colored black are transparent. When set to 1, black is solid."
data "When set to 0, the backside of the object is visible. When set to 1, it is not visible."
data "When set to 0, the texture is not effected. When set to 1, it softens (blurs) the texture."
data "When set to 0, the object will not be effected by light changes. When set to 1, light will have effect on object."
data " When set to 0, fog does not effect object. When set to 1, fog will have an effect on object."
data "When set to 0, object is not effected by ambient light. When set to 1, object is effected by ambient light."
data "The ambient light is being increased."
data "The ambient light is being decreased."
data "The fog is moving away."
data "The fog is moving closer."
data "The plain object is showing. The box and sphere are hidden."
data "The box object is showing. The plain and sphere are hidden."
data "The sphere object is showing. The plain and box are hidden."
data "The plain, box and sphere are textured with the orb texture (image 1)."
data "The plain, box and sphere are textured with the window texture (image 3)."
data "The camera is placed at the most extreme distance from the scene and resets camera angle to 0."
data "The camera is placed at the midway distance from the scene."
data "The camera is placed inside the center object."
data "The camera is being tilted down."
data "The camera is being tilted up."
data "The backdrop is on and objects will not leave trails as they move."
data "The backdrop is off and objects will leave a trail as they move.(cool huh?)"
data "WIREFRAME SETTINGS (FLAG) (a / q)", "TRANSPARENCY SETTINGS (FLAG) (s / w)", "CULL SETTINGS (FLAG) (d / e)", "FILTER SETTINGS (FLAG) (f / r)"
data "LIGHT SETTINGS (FLAG) (g / t)", "FOG SETTINGS (FLAG) (h / y)", "AMBIENT SETTINGS (FLAG) j / u)"
data "AMBIENT LIGHT ADJUSTMENTS (2 / 5)", "FOG DISTANCE ADJUSTMENTS (0 / 1)", "CHANGE MAIN OBJECT (z / x / c)", "CHANGE TEXTURE (v / b)", "RELOCATING CAMERA (3 / 6 / 9)"
data "TILTING CAMERA (upkey / downkey)", "BACKDROP ADJUSTMENTS (controlkey / shiftkey)"