Fast way of detecting if any of 15 bullets hit 16 tanks

andreww
02-28-2002, 08:42 AM
i am making a game with 16 tanks, which fire one shot then reload for a few seconds , mean while the shot it has fired will expire before the tank reaches fire time again

i am doing this to make the arrays faster, so what im doing is

detecting if any of the 15 shots(not including own shot)

hits each tank, ie.

For s = 1 to 15
For t = 1 to 16

if Bullet(s)= TankPosition(t) then DamageTank
next t
next s

in my collision detection i am basically checking if the bullet moves inside of 4 points ie

. .


. .


i was wondering if there is a better/faster way of detecting whether the bullets have hit any of the 16 tanks

remember there will be heaps of other code, so this collision detection that i will be using wont be the only code there.

Squirm
02-28-2002, 09:04 AM
PtInRect API?

andreww
02-28-2002, 09:24 AM
the four points wont always be square..i have them moving around a point

Iceplug
02-28-2002, 10:03 AM
So, the four points could be anywhere? Like
@ | @
@ |
|@ @
@|
@ | @
this?
There's probably some kind of API call that can do this.

(I knew it :cool: )

Squirm
02-28-2002, 10:08 AM
That being PtInRegion but since you have to create a region for this using CreatePolygonRgn so it could be pretty slow.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum