Hi
I was doing a little debuggin on my current game, because I had a problem with some of the enemy blocks (red) passing though the moveable objects (everything els), well I descovered that at some points, two or more red objects hit the white barriers and are pushed into each other, my theory is, that this is causing the collision for those objects to be cancelled out, and thus they no longer respond to collision. I need help in getting these objects (red) from cacelling each other out. Here is the code...
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)
dim selection(0)
dim player(0)
dim timeleft(0)
dim wavetime(0)
dim mover(120)
dim victorytimer(0)
`important variables
selection(0)=0
player(0)=1
timeleft(0)=2000
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
position camera -100,100,-100
xrotate camera 90
position camera 100,300,0
do
set cursor 10,10: Print "Press Space bar to start level 1"
if spacekey()=1
gosub level1
endif
sync
loop
end
rem ============================
wave:
for e=6 to 15
move object e,.1
next e
return
wave2:
for e=100 to 150
move object e,.1
next e
return
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
endif
else
selection(0) = 0
endif
endif
return
level1:
rem the new mouse object(s) to play with (blue)
for t=1 to 5
make object cube t,10
set object collision to boxes t
color object t,RGB(0,0,150)
set object collision on t
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
for t=204 to 206
make object box t,30,10,10
set object collision on 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
set object collision to boxes m
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
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
`make wave one (red)
for e=6 to 15
make object cube e, 4
set object collision to boxes e
set object collision on 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
set object collision on 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
set object collision on 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)
if timeleft(0) > 0
gosub selection
endif
timeleft(0)=timeleft(0)-1
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
for e=6 to 15
k = object collision(e, 0)
if k > 0 and k < 20
if k <> selection(0)
hide object e
endif
endif
next e
for e=6 to 15
rem if object collision(e,202)
if object collision(e,0) = 202
hide object e
endif
next e
for e=100 to 120
rem if object collision(e,202)
if object collision(e,0) = 202
hide object e
endif
next e
for e=100 to 120
k = object collision(e, 0)
if k > 0 and k < 20
if k <> selection(0)
hide object e
endif
endif
next e
for e=6 to 15
t = object collision(e,0)
if t > 203 and t < 207
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 e
for e=100 to 120
t = object collision(e,0)
if t > 203 and t < 207
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 e
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
Another thing I would like to ask, is how to check if any of the red objects have passed a certain area in the level, like checking to see if they are at Z 400?
Thanks.
Guns arnt the problem, people are the problems, shoot all the people and guns arnt a problems anymore.