Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411471 Posts in 69369 Topics- by 58423 Members - Latest Member: antkind

April 23, 2024, 09:36:10 AM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)Experience with pixel-precise hitboxes
Pages: [1]
Print
Author Topic: Experience with pixel-precise hitboxes  (Read 2054 times)
MekanikDestructiwKommando
Level 3
***


Let's ROCK!


View Profile
« on: May 07, 2008, 11:16:54 PM »

Anyone have experience with pixel precise hitboxes? I'm imagining using the mask of an image, and comparing two masks (eg the mask of an explosion or weapon) with the masks of all characters/hittable objects. This way hit detection would be literally pixel-perfect  Cool. Has anyone done this? Or know how to do this? In any language?
Logged

Quote
There have always been interactive experiences that go beyond entertainment.  For example, if mafia games are too fun for you, then you can always join the mafia.
jjs
Level 0
***


Lean like a Chozo!


View Profile
« Reply #1 on: May 07, 2008, 11:42:09 PM »

Check out this thread: http://forums.tigsource.com/index.php?topic=1097.msg25675#msg25675

The most important optimization is to use bounding circles or boxes to see if there even could be a collision, before resorting to the expensive pixel-perfect check.
Logged
Zaphos
Guest
« Reply #2 on: May 08, 2008, 12:01:16 AM »

If you're using allegro, PPCol seems pretty good for this purpose.  For SDL, there is SDL_Collide.

If you google pixel perfect collision detection, you'll find it's a fairly well discussed thing, so you can probably find a bunch more implementations and some tutorials if you look.
Logged
Farbs
Man
Level 10
*


/Farbs


View Profile WWW
« Reply #3 on: May 08, 2008, 12:47:50 AM »

As a side note, I usually find it better to just use circles or rects since they can be tweaked to give the player a helping hand. Shmups sometimes do this by only colliding enemy bullets with the player's middle pixel.
Logged
Robotacon
Pixelhead
Level 3
******


Story mode


View Profile
« Reply #4 on: May 10, 2008, 10:51:12 PM »

The most important optimization is to use bounding circles or boxes to see if there even could be a collision, before resorting to the expensive pixel-perfect check.

Testing the bounding box before testing individual pixels isn't optimization, it's just straight thinking. How else do you know where the test is taking place? Moving the mask into map coordinates would be just silly, who would do that?

What I think everyone is trying to say is that you should only test overlapping rectangular areas, that way you automatically won't test pixels that don't matter.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic