Its been a while since i last checked this forum, and even thought this looks old, i'll post what the problem was and the solution i found, though a good test might prove me wrong.
Main problem was that you where asigning the ID of some Boxes you used for collision, to the red lines that appeared on screen. So, it would bassically detect collision with those lines also.
Now, correct me if im wrong, but is that right? I didn't think so, so i changed the range from wich you assigned those ID to the red lines.
Here is where i changed things...
You assign ID range 1 to 20 to Boxes, so i'll change the ID range of the red lines from 11-41 to 21-60.
for r=21 to 60
if sprite exist(r)
show sprite r
endif
`sprite r,sprite x(r),sprite y(r),2
`set sprite alpha r,100
`set sprite diffuse r,255,0,0
`Yscale#=(dist#*100)/length#
`stretch sprite r,sprite scale x(r),Yscale#
`offset sprite r,sprite width(r)/2,0
`rotate sprite r,angle#+270
next r
You created the red lines with a ID ranging from 11 to 50, but range 1 to 20 is already being used, so changed it to 21 to 60
if sprite exist(20+a) then delete sprite 20+a
sprite 20+a,cx#,cy#,2
set sprite alpha 20+a,100
set sprite diffuse 20+a,255,0,0
Yscale#=(dist#*100)/length#
Yscale#=length#-(length#-dist#)
stretch sprite 20+a,sprite scale x(20+a),Yscale#
offset sprite 20+a,sprite width(20+a)/2,0
rotate sprite 20+a,angle#+270
hide sprite 20+a
move sprite 20+a,sprite height(20+a)
Here is all the code as i tested it...
REM Project: LineofSight
REM Created: 4/16/2008 3:00:29 PM
REM
REM ***** Main Source File *****
REM
sync on
sync rate 100
for t=1 to 6
line 100,100,97+t,300
sync
next t
get image 2,97,100,103,300
sync
`suspend for key
dim cx2#(80)
dim cy2#(80)
dim cx3#(80)
dim cy3#(80)
box 0,0,20,20
get image 1,0,0,20,20,1
a#=1
l#=200
//for o=1 to 20
// sprite o,rnd(screen width()-100),rnd(screen height()-100),1
// offset sprite o,10,10
// set sprite priority o,1
//next o
color backdrop rgb(0,0,0)
do
cls
lightmap(mousex(),mousey(),l#,a#)
if upkey()=1
inc a#
endif
if downkey()=1
dec a#
endif
if rightkey()=1
inc l#
endif
if leftkey()=1
dec l#
endif
for r=21 to 60
if sprite exist(r)
show sprite r
endif
`sprite r,sprite x(r),sprite y(r),2
`set sprite alpha r,100
`set sprite diffuse r,255,0,0
`Yscale#=(dist#*100)/length#
`stretch sprite r,sprite scale x(r),Yscale#
`offset sprite r,sprite width(r)/2,0
`rotate sprite r,angle#+270
next r
text 0,0,"FPS:"+str$(screen fps())
sync
loop
function lightmap(cx#, cy#, length#, angle#)
for r=1 to 80
cx2#(r)=0
cy2#(r)=0
cx3#(r)=0
cy3#(r)=0
next r
for a=1 to 40
angle#=angle#+2
for l=1 to length# step 7
for o=1 to 20
if xyhit(cx2#(a),cy2#(a),o) =0
inc linea
endif
next o
if linea=20
length1#=l
angle#=wrapvalue(angle#)
cx2#(a) = cx# + cos(angle#) * length1#
cy2#(a) = cy# + sin(angle#) * length1#
endif
linea=0
next l
angle#=wrapvalue(angle#)
cx3#(a) = cx2#(a) + cos(angle#) * length#
cy3#(a) = cy2#(a) + sin(angle#) * length#
line cx#, cy#, cx2#(a), cy2#(a)
//dist#=sqrt((cx2#(a)-cx3#(a))^2+(cy2#(a)-cy3#(a))^2)
//dist#=sqrt((cx3#(a)-cx2#(a))^2+(cy3#(a)-cy2#(a))^2)
dist#=ABS(sqrt((cx#-cx2#(a))^2+(cy#-cy2#(a))^2))
//dist#=sqrt((cx2#(a)-cx#)^2+(cy2#(a)-cy#)^2)
if sprite exist(20+a) then delete sprite 20+a
sprite 20+a,cx#,cy#,2
set sprite alpha 20+a,100
set sprite diffuse 20+a,255,0,0
Yscale#=(dist#*100)/length#
Yscale#=length#-(length#-dist#)
stretch sprite 20+a,sprite scale x(20+a),Yscale#
offset sprite 20+a,sprite width(20+a)/2,0
rotate sprite 20+a,angle#+270
hide sprite 20+a
move sprite 20+a,sprite height(20+a)
next a
angle#=0
endfunction
Function xyhit(x,y,s)
coll=0
if sprite exist(s)
if x<sprite x(s)+sprite width(s)/2 and x>sprite x(s)-sprite width(s)/2
if y>sprite y(s)-sprite height(s)/2 and y<sprite y(s)+sprite height(s)/2
exitfunction 1
endif
endif
endif
endfunction 0
Tell me if its working the way it should.
Hope it helps.