## Hit Detection With Blits (as3)

• 745 Views
• 2 Replies
SmellyCheeseMan
SmellyCheeseMan
• Member since: Jul. 13, 2005
• Offline.
Forum Stats
Member
Level 03
Blank Slate
Hit Detection With Blits (as3) 2012-04-23 19:44:34

Alrighty so I got blitting down extremely well, its efficient and can handle over 1000 or so objects on screen. However, there is going to be a point where these objects, in my case "bullets" are going to hit the player. I've searched far and wide through many hit detection algorithms and safe to say I'm a bit lost with it all. This is in the theme of a danmaku shmup : Example

Brute forcing will simply just not work. I need some advice as to what algorithm I should use. I've contemplated using "buckets" and I've implemented it to the best of my abilities, but it needs more work.

PSvils
PSvils
• Member since: Feb. 3, 2010
• Offline.
Forum Stats
Member
Level 01
Game Developer
Response to Hit Detection With Blits (as3) 2012-04-24 02:59:25

At 4/23/12 07:44 PM, SmellyCheeseMan wrote: Alrighty so I got blitting down extremely well, its efficient and can handle over 1000 or so objects on screen. However, there is going to be a point where these objects, in my case "bullets" are going to hit the player. I've searched far and wide through many hit detection algorithms and safe to say I'm a bit lost with it all. This is in the theme of a danmaku shmup : Example

Brute forcing will simply just not work. I need some advice as to what algorithm I should use. I've contemplated using "buckets" and I've implemented it to the best of my abilities, but it needs more work.

How hard is it to simply get the distance between 2 objects, and check if it is smaller than their combined radius?
Or hell, use a circle as the collision shape for bullets, and a rectangle for the other objects, that should fit their shape I guess a bit better.

Either way, simple stuff. (Try the circle-circle collision detection first)

P.

MintPaw
MintPaw
• Member since: Jun. 11, 2006
• Offline.
Forum Stats
Member
Level 10
Programmer
Response to Hit Detection With Blits (as3) 2012-04-25 23:34:02

At 4/24/12 02:59 AM, PSvils wrote: How hard is it to simply get the distance between 2 objects, and check if it is smaller than their combined radius?
Or hell, use a circle as the collision shape for bullets, and a rectangle for the other objects, that should fit their shape I guess a bit better.

That^

Also, if you're really making a Touhou like game the player's hitbox is only one pixel, making your calculations even easier, just test the one centre pixel against the bullet's hitbox (which is normally a tad smaller then it looks)

Although circle based collision my not work. Seeing that you'll need to be very accurate in a game like this, you could do circle based collision to see if a bullet is very near the player, if so use a more extensive hitTest method to check if there is an actual collision.

If ya have something to say, PM me. I have a lot of time to spare.
Also never PM egg82.