🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Multiple targets...

Started by
9 comments, last by ViPeR007 24 years, 6 months ago
I am having a problem with detecting collision with multiple enemies. The code below should detect the collision of vulcan with either bot, bot2[1], bot2[2] (eventually they would all be detected because you would destory them all). The problem is that if I shoot bot first then it won''t detect collision with bot2[1] or bot2[2] but if I shoot bot2[1]/[2] first then I can destroy all of them. The code is practically identical so I don''t understand why it won''t work. Here it is: if ( (bot.attr & BOB_ATTR_VISIBLE) // (bot2[1].attr & BOB_ATTR_VISIBLE) // (bot2[2].attr & BOB_ATTR_VISIBLE)) { for (index=0; index<MAX_VULCAN; index++) { if ((vulcan[index].attr & BOB_ATTR_VISIBLE) && (vulcan[index].state == VULCAN_STATE_ON)) { if (Collision_BOBS(&bot, &vulcan[index])) { vulcan[index].state = VULCAN_STATE_OFF; Start_Burst(vulcan[index].x, vulcan[index].y, 68+rand()%12,54+rand()%10, bot.xv>>1, bot.yv>>1); Hide_BOB(&bot); boton = 2; score = score + 300; } if (Collision_BOBS(&bot2[1], &vulcan[index])) { vulcan[index].state = VULCAN_STATE_OFF; Start_Burst(vulcan[index].x, vulcan[index].y, 68+rand()%12,54+rand()%10, bot2[1].xv>>1, bot2[1].yv>>1); Hide_BOB(&bot2[1]); bot2on = 2; score = score + 300; } if (Collision_BOBS(&bot2[2], &vulcan[index])) { vulcan[index].state = VULCAN_STATE_OFF; Start_Burst(vulcan[index].x, vulcan[index].y, 68+rand()%12,54+rand()%10, bot2[2].xv>>1, bot2[2].yv>>1); Hide_BOB(&bot2[2]); bot3on = 2; score = score + 300; } } } } Does anyone see an error? Thanx, ViPeR
Advertisement
Hmm was bot suppose to be bot[0] by chance? I mean you have bot[1],bot[2],but where is bot[0]?If this isnt your problem oh well.
I think you didn''t mean to write // in the first line of code. Change it to //

Dance with me......

http://members.xoom.com/CJdeVos/index.htm

Oh damn.......it already is those straight lines (top to bottom).....hmmmm......

don''t know what is wrong......

Dance with me......

http://members.xoom.com/CJdeVos/index.htm

No, bot2[1] and bot2[2] were cloned off of just regular bot. And if that were the problem they wouldn''t display on the screen at all and they are.

Thanx,
ViPeR
Solved it, thanx for the input though.


ViPeR
would be kind of you to tell us what the solution is.....

Dance with me......

http://members.xoom.com/CJdeVos/index.htm

Well with that code there was no error :-) Stupid me thought that I was editing the Plasma Cannon''s code when I put (bot.attr & BOB_ATTR_VISIBLE) // (bot2[1].attr & BOB_ATTR_VISIBLE) // (bot2[2].attr & BOB_ATTR_VISIBLE) in but I really did it to the vulcan. I was testing with the plasma. Before it just had bot.attr & BOB_ATTR_VISIBLE and none of the others so that when I killed that bot first then it couldn''t even get into the if''s. Just one of my stupid errors, thanx for wanting to help though.

Thanx,
ViPeR
There is a much deeper problem here. You are using Andre Lamothe''s GPDUMB game engine. Take some advice and don''t use it--it''s slow and lacks any redeeming features, kinda like Andre Lamothe''s books.
I beg to differ, acw... I used the GPDUMB engine for my last game (first game), and, granted, it''s slower than writing for yourself, but it''s good for a quick entry into writing games. This time around, I''m writing everything myself, but it was nice being able to only focus on the game the first time around, and not on boring DirectX stuff...

This topic is closed to new replies.

Advertisement