Hi
I have been gone for a while, did you miss me? Oh well, I will be gone even more once I start learning c++, oh the horror! I thought with the recent compo, I would maybe try and complete a project, and enter it, but I have been hitting a wall. The problem is collision, I have a bunch of enemy models that are supposed to run up the screen toward the players models, he can position different obstacles to try and stop all the advancing enemies, if there is a hole in his defences, and an enemy slips throuhg, the player loses. The idea is that when and enemy touches an defensive object, it dissapears (for now atleast), but my collision detection doesnt seem to work, the enemies can walk right though the objects I have set up to kill them, even though they should dissapear. Well all my explaining cant do any good without my code, so here it is
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)
selection(0)=0
player(0)=1
timeleft(0)=600
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)
next t
`make enemy
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
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
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
exit
endif
Next k
next e
`!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
rem print timer
set cursor 0,0
print "Player ",player(0)," Has ",timeleft(0)," Time Left "
if timeleft(0)=>0
gosub selection
endif
selection:
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(0)=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)=0
position object t,object position x(20),object position y(20),object position z(20)
selection(0)=1
endif
endif
endif
endif
endif
endif
endif
next t
endif
selection(0)=0
endif
return
if player(0)=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)=0
position object k,object position x(20),object position y(20),object position z(20)
selection(0)=1
endif
endif
endif
endif
endif
endif
endif
next k
endif
selection(0)=0
endif
return
timeleft(0)=timeleft(0)-1
if timeleft(0)=<0
if player(0)=1
gosub wave
center text 70,400, "WAVE 1 INBOUND!"
set cursor 10,10
print "use the objects at your disposal to keep the enemy at bay"
timeleft(0)=0
endif
endif
if returnkey()=1 then cls
sync
loop
wave:
for e=6 to 15
move object e,.1
next e
return
I have placed exclemation markes above and below the collision code.
Any help would be greatly appreciated.
Thank you!
Guns arnt the problem, people are the problems, shoot all the people and guns arnt a problems anymore.