follow this rule for programs
setup
beginloop
gosub/functions
endloop
functions
gosubs
your code had placed the gosub "selection" smack in the middle of the main loop, I moved it too the end of the code (and removed the variable(0) bit because it is not needed in this case).
wave 1 hits the mines and gets killed, you have to delete them or place them at adistant location, if you just hide them then they still have collision and will kill the player, wave 2 does not respond to the minefield since you didn`t code the collision checks for the objects, heres the tweaked code.
rem Init display
randomize timer()
set display mode 1024,768,32
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)
selection=0
player=1
timeleft=200
wavetime=200
rem the new mouse object to play with
make object cube 20,10
position object 20,-100,0,-100
set object collision to polygons 20
color object 20,RGB(0,0,150)
ghost object on 20
hide object 20
rem the new mouse object(s) to play with
for t=1 to 5
make object cube t,10
position object t,100+rnd(50),0,100+rnd(50)
set object collision to polygons t
color object t,RGB(0,0,150)
set object collision on t
next t
`make wave one
for e=6 to 15
make object cube e, 4
position object e,100+rnd(60),0,-100+rnd(60)
color object e,RGB(255,0,0)
set object collision to boxes e
set object collision on e
next e
`make wave two
for e=100 to 150
make object cube e,4
position object e,100+rnd(100),0,-400+rnd(100)
color object e,RGB(255,0,0)
set object collision to boxes e
set object collision on e
next e
`make landmines
for k=16 to 19
make object cube k,3
position object k,100+rnd(50),0,80+rnd(50)
color object k,RGB(0,255,0)
set object collision to boxes k
set object collision on k
next k
position camera -100,100,-100
xrotate camera 90
position camera 100,300,0
do
for e=6 to 15
for k=16 to 19
if object collision(e,k)=1
hide object e
endif
Next k
next e
rem print timer
set cursor 0,0
print "Player ",player," Has ",timeleft," Time Left "
if timeleft=>0
gosub selector
endif
timeleft=timeleft-1
if timeleft=<0
if player=1
gosub wave
wavetime=wavetime-1
center text 70,400, "WAVE 1 INBOUND!"
set cursor 10,10
print "use the objects at your disposal and keep the enemy at bay for " ,wavetime/1000," seconds"
timeleft=0
endif
endif
if returnkey()=1 then cls
if wavetime=<0
wavetime=0
endif
for e=6 to 15
if wavetime=0
hide object e
center text 70,600,"wave 2 inbound!"
gosub wave2
endif
next e
sync
loop
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
selector:
rem the new object selection code
if object screen x(20)=<mousex()
position object 20,object position x(20)+4,object position y(20),object position z(20)
endif
if object screen x(20)=>mousex()
position object 20,object position x(20)-4,object position y(20),object position z(20)
endif
if object screen y(20)=<mousey()
position object 20,object position x(20),object position y(20),object position z(20)-4
endif
if object screen y(20)=>mousey()
position object 20,object position x(20),object position y(20),object position z(20)+4
endif
if player=1
rem the select bit (replace with distance equation) Player 1
if mouseclick()=1
for t=1 to 5
if object position x(20)=<object position x(t)+10
if object position x(20)=>object position x(t)-10
if object position y(20)=<object position y(t)+10
if object position y(20)=>object position y(t)-10
if object position z(20)=<object position z(t)+10
if object position z(20)=>object position z(t)-10
if selection=0
position object t,object position x(20),object position y(20),object position z(20)
selection=1
endif
endif
endif
endif
endif
endif
endif
next t
endif
selection=0
endif
return
if player=1
rem the select bit (replace with distance equation) Player 1
if mouseclick()=1
for k=16 to 19
if object position x(20)=<object position x(k)+10
if object position x(20)=>object position x(k)-10
if object position y(20)=<object position y(k)+10
if object position y(20)=>object position y(k)-10
if object position z(20)=<object position z(k)+10
if object position z(20)=>object position z(k)-10
if selection=0
position object k,object position x(20),object position y(20),object position z(20)
selection=1
endif
endif
endif
endif
endif
endif
endif
next k
endif
selection=0
endif
return
you might like to adjust the random positioning of the blue objects so that they don`t intersect, to do that use a repeat until loop to check for object collision at the random position and then keep repositioning them until they don`t collide...eg:
repeat
position object x,rnd(100),0,rnd(100)
until object collision (x,0)=0
will keep positioning the object until it is not in collision with anything, hope thats some help.
Mentor.
PC1: P4 3ghz, 1gig mem, 2x160gig hd`s, Radeon 9800pro w cooler (3rd gfx card), 6 way speakers.
PC2: AMD 2ghz, 512mb ram, FX5200 ultra, 16 bit SB.
Mini ATX cases suck.