Ok this is really wierd, After looking over the code I have made several descoveries. Number 1, is that only one of level1's barriers is detecting collision, the second descovery, is that every object in level 2 moves the red object left and right, even though they are not supposed to! Here is the code as of now....
randomize timer()
set display mode 1024,768,16
sync on
sync rate 60
autocam off
Set camera range 1,10000
position mouse screen width()/2, screen height()/2
backdrop on
color backdrop rgb(0,0,0)
`ARRAYS!
dim selection(0)
dim player(0)
dim timeleft(0)
dim wavetime(0)
dim mover(360)
dim victorytimer(0)
`important variables
selection(0)=0
player(0)=1
timeleft(0)=1000
victorytimer(0)=1000
wavetime(0)=1000
rem the new mouse object to play with
make object cube 8000,10
position object 8000,100,0,100
set object collision to boxes 8000
color object 8000,RGB(128,128,0)
hide object 8000
`Camera positioning
position camera -100,100,-100
xrotate camera 90
position camera 100,300,0
`MAIN loop!!!!!!!!
do
set cursor 10,10: Print "Press Space bar to start level 1"
if downkey()=1
gosub level1
endif
if upkey()=1
gosub level2
endif
sync
loop
end
rem ============================
`Wave 1 subroutine (sends the first set of red object upwards at a constant pace)
wave:
for e=6 to 15
move object e,.1
next e
return
`Wave 2 subroutine (sends the second set of red objects upwards at a constant pace)
wave2:
for e=100 to 120
move object e,.1
next e
return
`!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
`Selection code, allows you to select objects,and move them around "IMPORTANT"!!!!
`!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
selection:
rem the new object selection code
rem -- here we move the user selection cube...
if object screen x(8000)=<mousex()
position object 8000,object position x(8000)+4,object position y(8000),object position z(8000)
endif
if object screen x(8000)=>mousex()
position object 8000,object position x(8000)-4,object position y(8000),object position z(8000)
endif
if object screen y(8000)=<mousey()
position object 8000,object position x(8000),object position y(8000),object position z(8000)-4
endif
if object screen y(8000)=>mousey()
position object 8000,object position x(8000),object position y(8000),object position z(8000)+4
endif
rem the select bit (replace with distance equation) Player 1
if player(0)=1
if mouseclick()=1
rem -- here we move any object selected by the user
if selection(0)
position object selection(0),object position x(8000),object position y(8000),object position z(8000)
else
t = object collision(8000,0)
rem -- here we test for all user movable objects...
if t > 0 and t < 6
selection(0) = t
endif
if t > 15 and t < 20
selection(0) = t
endif
if t > 199 and t < 207
selection(0) = t
endif
if t >299 and t < 320
selection(0) = t
endif
endif
else
selection(0) = 0
endif
endif
return
`Beginning of the level 1 subroutine, everything pertaining to the level goes in here!!!!!!
level1:
`makes the blue objects, that kill the red objects.
for t=1 to 5
make object cube t,10
set object collision to boxes t
color object t,RGB(0,0,150)
position object t,100+rnd(50),0,100+rnd(50)
while object collision(t,0) > 0
position object t,100+rnd(50),0,100+rnd(50)
endwhile
next t
`make barriers (white)
for t=204 to 206
make object box t,30,10,10
set object collision to boxes t
position object t, 100+rnd(50), 0,100+rnd(50)
next t
rem make machine gun nest A
m= 201
make object cube m, 10
color object m,RGB(90,90,40)
Position object m,100,0,100
rem make bullets
for b=207 to 208
make object sphere b,2
next b
`positions the bullets in the machine gun.
for b=207 to 208
position object b,object position x(m),object position y(m),object position z(m)
next b
`make machine gun nest target
t = 202
make object box t,30,5,10
color object t,RGB(90,90,90)
position object t,100,0,-100
set object collision to boxes t
`make wave one (red)
for e=6 to 15
make object cube e, 4
set object collision to boxes e
color object e,RGB(255,0,0)
position object e,100+rnd(100),0,-200+rnd(100)
while object collision(e,0) > 0
position object e,100+rnd(100),0,-200+rnd(100)
endwhile
next e
`make wave two (red)
for e=100 to 120
make object cube e,4
color object e,RGB(255,0,0)
set object collision to boxes e
position object e,100+rnd(200),0,-300+rnd(200)
while object collision(e,0) > 0
position object e,100+rnd(200),0,-300+rnd(200)
endwhile
next e
`make landmines (green)
for k=16 to 19
make object cube k,3
color object k,RGB(0,255,0)
set object collision to boxes k
position object k,100+rnd(50),0,80+rnd(50)
while object collision(k,0) > 0
position object k,100+rnd(50),0,80+rnd(50)
endwhile
next k
do
rem print timer
set cursor 0,0
print "Player ",player(0)," Has ",timeleft(0)," Time Left ", "time to victory", victorytimer(0)
`lets you manipulate the objects if the time is above 0!
if timeleft(0) > 0
gosub selection
endif
`timer!
timeleft(0)=timeleft(0)-1
`All that timing crap!
if timeleft(0)=<0
if player(0)=1
victorytimer(0)= victorytimer(0)-1
gosub wave
wavetime(0)=wavetime(0)-1
center text 70,400, "WAVE 1 INBOUND!"
set cursor 10,10
print "A second wave of enemys has been spotted on the horizon, time untill landing " ,wavetime(0),"milliseconds"
timeleft(0)=0
endif
endif
if returnkey()=1 then cls
if wavetime(0)=<0
wavetime(0)=0
endif
for e=6 to 15
if wavetime(0)=0
hide object e
center text 70,600,"wave 2 inbound!"
gosub wave2
endif
next e
if victorytimer(0)=<0
set cursor 10,20: print "This is a great victory, without a beach-head here, the enemy will lose a valuable foot hold, you win the fight!"
endif
`Collision for the first wave of enemies
for e=6 to 15
p = object collision(e, 0)
if p > 0 and p < 20
if p <> selection(0)
hide object e
endif
endif
next e
`Collision between first wave and machine gun nest target (202)
for e=6 to 15
rem if object collision(e,202)
if object collision(e,0) = 202
hide object e
endif
next e
`collision between second wave and machine gun nest target (202)
for e=100 to 120
rem if object collision(e,202)
if object collision(e,0) = 202
hide object e
endif
next e
`collision for second wave
for e=100 to 120
p = object collision(e, 0)
if p > 0 and p < 20
if p <> selection(0)
hide object e
endif
endif
next e
`!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
`Checks for collision between wave 1, and the white barriers, and moves the red objects left or right if collision is present
For e = 6 To 15
For i = 204 To 206
If Object Collision(e,i)
print "collision detected"
`Do whatever to do when white hit's red here
if mover(e) = 0
if rnd(10) > 5
mover(e) = 5
else
mover(e) = -5
endif
endif
position object e, object position x(e)+mover(e), object position y(e), object position z(e)
else
mover(e) = 0
endif
Next i
Next e
`Same thing as above, but moves the second wave left or right if they hit the barriers
For e = 100 To 120
For i = 204 To 206
If Object Collision(e,i)
print "collision detected"
`Do whatever to do when white hit's red here
if mover(e) = 0
if rnd(10) > 5
mover(e) = 5
else
mover(e) = -5
endif
endif
position object e, object position x(e)+mover(e), object position y(e), object position z(e)
else
mover(e) = 0
endif
Next i
Next e
`Fires the bullet from the gun, towards the target.
fire=1
for b=207 to 208
t = 202
if fire=1
point object b,object position x(t),object position y(t),object position z(t)
move object b, 10
endif
rem if object collision(b,t)>0
if object collision(b,0) = t
fire=0
position object b,object position x(m),object position y(m),object position z(m)
endif
next b
sync
loop
return
`Level 2
level2:
cls
timeleft(0)=timeleft(0)-1
set cursor 0,0
print "Player ",player(0)," Has ",timeleft(0)," Time Left "
`Barriers
for b=300 to 302
make object box b,30,10,10
set object collision to boxes b
position object b, 100+rnd(100), 0, 90+rnd(100)
next b
`landmines
For m=303 to 310
make object cube m, 3
color object m, RGB(0,255,0)
set object collision to boxes m
position object m, 100+rnd(50), 0, -100+rnd(100)
next m
`big blue killy thingys
for t=311 to 315
make object cube t, 10
color object t, RGB(0,0,255)
set object collision to boxes t
position object t, 100+rnd(50), 0, 100+rnd(50)
next t
`nest A
a=316
make object box a, 30, 10,10
color object a, RGB(90, 50,50)
position object a, 100+rnd(50), 0, 50+rnd(50)
`target A
b=317
make object box b, 30, 10,10
color object b, RGB(50,50,50)
position object b, 100+rnd(50), 0, 50+rnd(100)
set object collision to boxes b
`nest b
c=318
make object box c, 30,10,10
color object c, RGB(90, 50, 50)
position object c, 100+rnd(50),0, 90+rnd(50)
`target b
d=319
make object box d, 30,10,10
color object d, RGB(50,50,50)
Position object d, 150+rnd(50),0,100+rnd(50)
set object collision to boxes d
`make bullets A
for b=2000 to 2002
make object sphere b, 2
next b
`position the bullet in nest A
for b=2000 to 2002
position object b, object position x(a), object position y(a), object position z(a)
next b
`make bullets for nest c
for b=2003 to 2005
make object sphere b, 2
next b
for b=2003 to 2005
position object b, object position x(c), object position y(c), object position z(c)
next b
`make flag
f=320
make object box f,5, 50, 5
color object f, RGB(50,0,10)
set object collision to boxes f
position object f, 100, 0, 100
`make enemies
for e=321 to 340
make object cube e, 3
color object e, RGB(255,0,0)
position object e, 200+rnd(50),0,100+rnd(100)
set object collision to boxes e
next e
`make enemies 2
for e=341 to 350
make object cube e, 3
color object e, RGB(255,0,0)
position object e, 100+rnd(50),0,-300+rnd(100)
set object collision to boxes e
next e
`make enemies 3
for e=351 to 360
make object cube e,3
color object e, RGB(255,0,0)
position object e, -200+rnd(50),0,300+rnd(100)
set object collision to boxes e
next e
for e=321 to 360
point object e, object position x(f), object position y(f), object position z(f)
next e
do
for e=321 to 360
if timeleft(0)<0
move object e,.1
endif
next e
`Time countdown
if timeleft(0)>0
gosub selection
endif
`timer!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
timeleft(0)=timeleft(0)-1
set cursor 0,0
print "Player ",player(0)," Has ",timeleft(0)," Time Left "
`Fires the bullet from the gun, towards the target.
fire=1
for b=2000 to 2002
t = 317
if fire=1
point object b,object position x(t),object position y(t),object position z(t)
move object b, 10
endif
rem if object collision(b,t)>0
if object collision(b,0) = t
fire=0
position object b,object position x(a),object position y(a),object position z(a)
endif
next b
`Fires the bullet from the gun, towards the target.
fire=1
for b=2003 to 2005
t = 319
if fire=1
point object b,object position x(t),object position y(t),object position z(t)
move object b, 10
endif
rem if object collision(b,t)>0
if object collision(b,0) = t
fire=0
position object b,object position x(c),object position y(c),object position z(c)
endif
next b
`turn barriers left and right
for b=300 to 302
if rightkey()=1
turn object right b , 1
endif
next b
for b=300 to 302
if leftkey()=1
turn object left b, 1
endif
next b
`OMFG ITS COLLISION! RUN FOR THE HILLS! COVER YOUR CHILDRENS EYES, LET THE LORD HAVE MERCEY ON MY SOUL!
`checks collision for the red ojects
for e=321 to 360
k = object collision(e, 0)
if k > 299 and k < 316
if k <> selection(0)
hide object e
endif
endif
next e
`checks collision between red objects and Target A
for e=321 to 360
if object collision(e,317)
hide object e
endif
next e
`checks collision between red objects and target B
for e=321 to 360
if object collision(e,319)
hide object e
endif
next e
`checks for collision between the white barriers and the red objects, and moves the red objects
For e = 321 To 360
For b = 300 To 302
If Object Collision(e,i)
`Do whatever to do when white hit's red here
if mover(e) = 0
if rnd(10) > 5
mover(e) = 5
else
mover(e) = -5
endif
endif
position object e, object position x(e)+mover(e), object position y(e), object position z(e)
else
mover(e) = 0
endif
Next b
Next e
sync
loop
return
Now here is the really wierd part, notice the object variables set up there....
For e = 321 To 360
For b = 300 To 302
If Object Collision(e,i)
`Do whatever to do when white hit's red here
if mover(e) = 0
if rnd(10) > 5
mover(e) = 5
else
mover(e) = -5
endif
endif
position object e, object position x(e)+mover(e), object position y(e), object position z(e)
else
mover(e) = 0
endif
Next b
Next e
Now notice how I didn't change them when checking collision, the code is checking collision between e and i, even though I never set up a object to be i, yet the collision works

, but works a little to much, in fact every object in the level now moves the red objects around, even though only the white objects should

. Now it gets even stranger, when I change the (e,i) to (e,b) to check collision the right way, the collision no longer works, and it becomes the same exact problem that level 1 has. Weird! I am thinking that this is happening... instead of checking collision between e and b, it is checking collision between e and everything, that would eplain why everything moves the red object around. But what really gets me, is why when I correct the variables, the collision stops working? Any suggestians?
UPDATE: Ok I might have jumped the gun before, becuase it seems that after the timer reaches 0 or below, the collision for level 2 begins to work correctly, so that is fixed, however the problems from level 1 persist.
Guns arnt the problem, people are the problem, shoot all the people and guns arnt a problem anymore.