Yes, the spot light is my ambient light.
I understand what you are saying, but a weird thing happens:
when I have it set to set spot light 0,90,180 I see no light.
But when it is set spot light 0,180,360 it is as if I have not turned ambient light off!
It isn't a gradual transition either, It just suddenly jumps (at least I think it does. I haven't been able to find the exact point it makes the difference).
My code follows, so you can see what I am talking about. Warning: it is an entire game that I am working on, so it is long. Then lighting parts have been pointed out with an obscene number of comment lines.
#include "title.dba"
hide mouse
dim xs#(106)
dim zs#(106)
load music "media/music.mid",1
loop music 1
begin:
for a = 1 to 65000
if object exist(a) then delete object a
next a
cs = 0
cs2 = 0
pexpandd = 0
pexpandu = 0
`LIGHTS
`***************************************************************************
`***************************************************************************
`***************************************************************************
`/////////////////*******************************************\\\\\\\\\\\\\\\
`NOTICE THIS!
set spot light 0,180,180
set light range 0,1000
rotate light 0,90,0,0
color light 0,rgb(255,0,0)
load sound "media/bounce.wav",1
load sound "media/explode.wav",2
option = menu()
if option = 4 then end
ink rgb(255,0,0),0
lv = 1
score = 0
start:
life = lv + 1
num2 = 35000
xpos# = 0
zpos# = 0
randomize timer()
for a = 6 to 106
xs#(a) = rnd(1)
if xs#(a) = 0 then xs#(a) = -1
zs#(a) = rnd(1)
if zs#(a) = 0 then zs#(a) = -1
next a
sync on
autocam off
hide mouse
num = 1000
gosub setup
gosub createballs
set global collision on
make object box 300,5,5,40
pos = 1
set object 300,0,0,0
color object 300,rgb(0,0,255)
cs = 0
cs2 = 0
load image "media/jezz.bmp",1
load image "media/moss.bmp",2
texture object 1,1
texture object 2,2
texture object 3,2
texture object 4,2
texture object 5,2
onumu = 12345
onumd = 12346
oldnumu = 0
`*****************************************************************************************************
`**********************************MAIN LOOP BEGINS***************************************************
`*****************************************************************************************************
do
`MORE LIGHTS*************************************************
`************************************************************
set light to object position 0,300
if mouseclick()=2 then mp = 1
if mp = 1 and mouseclick() = 0
yrotate object 300,wrapvalue(object angle y(300)+90)
mp = 0
endif
if mouseclick()=1 then mp2 = 1
`PEXPANDu***************************************************************
if pexpandu = 1
if direction = 0 or direction = 180
if object exist(pexnumu) = 1 then delete object pexnumu
make object box pexnumu,5,10,15+cs
position object pexnumu,sposx,0,sposz + (10+cs)/2
yrotate object pexnumu,direction
else
if object exist(pexnumu) = 1 then delete object pexnumu
make object box pexnumu,5,10,15+cs
position object pexnumu,sposx + (10+cs)/2,0,sposz
yrotate object pexnumu,direction
endif
mp2 = 0
cs = cs + 2
color object pexnumu,rgb(255,0,0)
for a = 2 to 5
if object collision(pexnumu,a) = 1
pexpandu = 0
cs = 0
pexnumu = 0
goto out2
endif
next a
for a = 1000 to num
if object exist(a)
if object collision(pexnumu,a) = 1 and a <> cnumd and a <> cnumu
pexpandu = 0
cs = 0
pexnumu = 0
goto out
endif
endif
next a
for a = 2000 to num+1000
if object exist(a)
if object collision(pexnumu,a) =1 and a <> cnumd and a <> cnumu
pexpandu = 0
cs = 0
pexnumu = 0
goto out
endif
endif
next a
for a = 35000 to num2
if object exist(a)
if object collision(pexnumu,a) =1
pexpandu = 0
cs = 0
pexnumu = 0
goto out
endif
endif
next a
endif
out2:
`******************************************PEXPANDd
if pexpandd = 1
if direction = 0 or direction = 180
if object exist(pexnumd) = 1 then delete object pexnumd
make object box pexnumd,5,10,15+cs2
position object pexnumd,sposx,0,sposz - (10+cs2)/2
yrotate object pexnumd,direction
else
if object exist(pexnumd) = 1 then delete object pexnumd
make object box pexnumd,5,10,15+cs2
position object pexnumd,sposx - (10+cs2)/2,0,sposz
yrotate object pexnumd,direction
endif
mp2 = 0
cs2 = cs2 + 2
color object pexnumd,rgb(0,0,255)
for a = 2 to 5
if object collision(pexnumd,a) = 1
pexpandd = 0
cs2 = 0
pexnumd = 0
goto out
endif
next a
for a = 1000 to num
if object exist(a)
if object collision(pexnumd,a) = 1 and a <> cnumd and a <> cnumu
pexpandd = 0
cs2 = 0
pexnumd = 0
goto out
endif
endif
next a
for a = 2000 to num+1000
if object exist(a)
if object collision(pexnumd,a) =1 and a <> cnumd and a <> cnumu
pexpandd = 0
cs2 = 0
pexnumd = 0
goto out
endif
endif
next a
for a = 35000 to num2
if object exist(a)
if object collision(pexnumd,a) =1
pexpandd = 0
cs2 = 0
pexnumd = 0
goto out2
endif
endif
next a
endif
out:
if mouseclick()=0 and mp2 = 1
pexnumu2 = pexnumu + 2000
pexnumd2 = pexnumu + 3000
pexnumu = num
pexnumd = num + 1000
num = num + 1
cnumu = pexnumu
cnumd = pexnumd
onumu = pexnumu
onumd = pexnumd
sposx = object position x(300)
sposz = object position z(300)
pexpandu = 1
pexpandd = 1
direction = object angle y(300)
mp2 = 0
endif
gosub ballcollision
if pexpandu = 0 and pexpandd = 0 then gosub combine
if oldnumu > 0 then gosub check_horizontal
if oldnumu > 0 then gosub check_vertical
position object 300,0+((mousex()-320)*1.000),6,0-((mousey()-240)*1.000)
ink rgb(255,255,255),0
text 100,0,"Lives: " + str$(life)
center text 320,0,"Score: " + str$(score)
if life < 1
while spacekey() = 0
set text size 72
set text font "Courier New"
center text 320,200,"GAME OVER"
set text size 24
center text 320,300,"Press Space Key to Continue"
sync
endwhile
delete light 1
goto begin
endif
gosub ballcheck
set cursor 0,0
print str$(light position x(1))
print str$(light position z(1))
sync
loop
`*******************SUB ROUTINES****************
check_horizontal:
if object exist(oldnumu) = 1
test = 0
for a = 35000 to num2+1
if object exist(a)
if object collision(oldnumu,a) = 1 then test = test + 1
endif
next a
if test = 1 and object collision(oldnumu,4) = 1 then test = 2
if test = 1 and object collision(oldnumu,5) = 1 then test = 2
if object collision(oldnumu,4) =1 and object collision(oldnumu,5) = 1 then test = 2
cz = object position z(oldnumu)
sx = object size z(oldnumu)
cx = object position x(oldnumu)
test = 0
test2 = 0
for a = 6 to lv+6
if object position z(a) > cz then test = test + 1
if object position z(a) < cz then test2= test2+ 1
next a
if test = lv+1
make object box num2,cz+200,99,sx
position object num2,cx,1,object size x(num2)/2 - 200
yrotate object num2,direction
delete object oldnumu
texture object num2,2
score = score + (object size x(num2) * sx)/100
endif
if test2= lv+1
make object box num2,200-cz,99,sx
position object num2,cx,1,-1*((object size x(num2)/2)-200)
yrotate object num2,direction
delete object oldnumu
texture object num2,2
score = score + (object size x(num2) * sx)/100
endif
num2 = num2 + 1
endif
return
`CHECK VERTICAL
check_vertical:
if object exist(oldnumu) = 1
test = 0
for a = 35000 to num2+1
if object exist(a)
if object collision(oldnumu,a) = 1 then test = test + 1
endif
next a
if test = 1 and object collision(oldnumu,4) = 1 then test = 2
if test = 1 and object collision(oldnumu,5) = 1 then test = 2
if object collision(oldnumu,4) =1 and object collision(oldnumu,5) = 1 then test = 2
if test = 2
cz = object position z(oldnumu)
sx = object size x(oldnumu)
cx = object position x(oldnumu)
test = 0
test2 = 0
for a = 6 to lv+6
if object position z(a) > cz then test = test + 1
if object position z(a) < cz then test2= test2+ 1
next a
if test = lv+1
make object box num2,cx+200,99,sx
position object num2,object size z(num2)/2 - 200,1,cz
yrotate object num2,direction
delete object oldnumu
texture object num2,2
score = score + (object size x(num2) * sx)/100
endif
if test2= lv+1
make object box num2,cx+200,99,sx
position object num2,-1*(object size z(num2)/2-200),1,cz
yrotate object num2,direction
delete object oldnumu
texture object num2,2
score = score + (object size x(num2) * sx)/100
endif
num2 = num2 + 1
endif
endif
return
`*************C**O**M**B**I**N**E**************
`half the width of both + the bottom of the bottom block to reposition big block
combine:
if object exist(onumu) = 1 and object exist(onumd) = 1
if direction = 90 or direction = 270
wu = object size z(onumu)
wd = object size z(onumd)
bottom = object position x(onumd) - wd/2
oz = object position z(onumu)
oxs = wu+wd
opx = bottom + oxs/2
delete object onumu
delete object onumd
make object box onumu,5,10,oxs
position object onumu,opx,0,oz
yrotate object onumu,direction
color object onumu,rgb(255,0,0)
else
wu = object size z(onumu)
wd = object size z(onumd)
bottom = object position z(onumd) - wd/2
ox = object position x(onumu)
ozs = wu+wd
opz = bottom + ozs/2
delete object onumu
delete object onumd
make object box onumu,5,10,ozs
position object onumu,ox,0,opz
yrotate object onumu,direction
color object onumu,rgb(255,0,0)
endif
oldnumu = onumu
onumu = 12345
onumd = 12346
endif
return
`BALL COLLISION*********************************
ballcollision:
for a = 6 to lv+6
yrotate object a,0
move object a,zs#(a)
yrotate object a,90
move object a,xs#(a)
position object a+10000,object position x(a)-odis,2,object position z(a)
position object a+20000,object position x(a)+odis,2,object position z(a)
position object a+30000,object position x(a),2,object position z(a)-odis
position object a+40000,object position x(a),2,object position z(a)+odis
if object collision(a+10000,0) > 0 and object collision(a+10000,0) <> 300
if object collision(a+10000,0) = pexnumd
pexpandd = 0
cs2 = 0
delete object pexnumd
life = life - 1
pexnumd = 0
if sound playing(2) = 0 then play sound 2
endif
if object collision(a+10000,0) = pexnumu
pexpandu = 0
cs = 0
delete object pexnumu
life = life - 1
pexnumu = 0
if sound playing(2) = 0 then play sound 2
endif
xs#(a) = rnd(3)
if sound playing(1) = 0 and sound playing(2) = 0 then play sound 1
endif
if object collision(a+20000,0) > 0 and object collision(a+20000,0) <> 300
if object collision(a+20000,0) = pexnumd
pexpandd = 0
cs2 = 0
life = life - 1
delete object pexnumd
pexnumd = 0
if sound playing(2) = 0 then play sound 2
endif
if object collision(a+20000,0) = pexnumu
pexpandu = 0
cs = 0
life = life - 1
delete object pexnumu
pexnumu = 0
if sound playing(2) = 0 then play sound 2
endif
xs#(a) = 0 - rnd(3)
if sound playing(1) = 0 and sound playing(2) = 0 then play sound 1
endif
if object collision(a+30000,0) > 0 and object collision(a+30000,0) <> 300
if object collision(a+30000,0) = pexnumd
pexpandd = 0
cs2 = 0
delete object pexnumd
life = life - 1
pexnumd = 0
if sound playing(2) = 0 then play sound 2
endif
if object collision(a+30000,0) = pexnumu
pexpandu = 0
cs = 0
delete object pexnumu
life = life - 1
pexnumu = 0
if sound playing(2) = 0 then play sound 2
endif
zs#(a) = rnd(3)
if sound playing(1) = 0 and sound playing(2) = 0 then play sound 1
endif
if object collision(a+40000,0) > 0 and object collision(a+40000,0) <> 300
if object collision(a+40000,0) = pexnumd
pexpandd = 0
cs2 = 0
delete object pexnumd
life = life - 1
pexnumd = 0
if sound playing(2) = 0 then play sound 2
endif
if object collision(a+40000,0) = pexnumu
pexpandu = 0
cs = 0
delete object pexnumu
life = life - 1
pexnumu = 0
if sound playing(2) = 0 then play sound 2
endif
zs#(a) = 0 - rnd(3)
if sound playing(1) = 0 and sound playing(2) = 0 then play sound 1
endif
next a
return
`CREATE BALLS*******************************
createballs:
for a = 6 to lv+6
load object "media/sphere.x",a
size2 = rnd(1000)+1000
scale object a,size2,size2,size2
xpos = rnd(400) - 200
zpos = rnd(400) - 200
odis = 8 + 2
position object a,rnd(300)-150,0,rnd(300)-150
make object cube a+10000,2
hide object a+10000
position object a+10000,xpos-odis,2,zpos
make object cube a+20000,2
hide object a+20000
position object a+20000,xpos-odis,2,zpos
make object cube a+30000,2
hide object a+30000
position object a+30000,xpos,2,zpos-odis
make object cube a+40000,2
hide object a+40000
position object a+40000,xpos,2,zpos+odis
next a
return
`SETUP**********************************
setup:
make object plain 1,400,400
xrotate object 1,90
position object 1,0,0,0
color object 1,rgb(150,130,150)
make object box 2,400,300,10
position object 2,0,-100,200
make object box 3,400,300,10
position object 3,0,-100,-200
make object box 4,400,300,10
position object 4,200,-100,0
yrotate object 4,90
make object box 5,400,300,10
position object 5,-200,-100,0
yrotate object 5,90
position camera 0,400,0
xrotate camera 90
color backdrop rgb(44,172,209)
return
`CHECK FOR OUTSIDE
ballcheck:
for a = 6 to lv+6
if object position x(a) < -200 and object position x(a) > 200
x = rnd(400)-200
else
x = object position x(a)
endif
if object position z(a) < -200 and object position x(a) > 200
z = rnd(400)-200
else
z = object position z(a)
endif
position object a,x,0,z
next a
return
Thank you SandraD for your time and effort.
"Computers in the future may weigh no more then
1.5 tons. - Popular Mechanics, 1949