Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Color collision

This thread is locked; no one can reply to it. rss feed Print
Color collision
miguel meza
Member #5,447
January 2005

Hi,well, in 2d fitghing game (dragon ball), when the player does a "special power" i use animated gif. And they have transparent parts.

I want to the collision detection something like this:
(this will for example when goku launchs a kamehameh)

if (the color of the player1.posX+player1.width is not transparent)
if (player1.posx+player1.width >= player2.posX )
collide = true

any ideas?

OICW
Member #4,069
November 2003
avatar

Pixel perfect collisions...
PixelMask or Ppcol.

[My website][CppReference][Pixelate][Allegators worldwide][Who's online]
"Final Fantasy XIV, I feel that anything I could say will be repeating myself, so I'm just gonna express my feelings with a strangled noise from the back of my throat. Graaarghhhh..." - Yahtzee
"Uhm... this is a.cc. Did you honestly think this thread WOULDN'T be derailed and ruined?" - BAF
"You can discuss it, you can dislike it, you can disagree with it, but that's all what you can do with it"

miguel meza
Member #5,447
January 2005

that is good, but it doesnt works perfeclty for what i want...

isnt there a way to do what i want?

Fladimir da Gorf
Member #1,565
October 2001
avatar

What do you want? If you need to read only one pixel from a player's bitmap, then use getpixel with a correct offset.

OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori)

miguel meza
Member #5,447
January 2005

i only need to know i a pixel in a certain position is transparent or not......
how can i do it?

SonShadowCat
Member #1,548
September 2001
avatar

if using something other than 8bit, you do( not 100% sure on what transparent color is):

if( _getpixel( whatever pixel) == makecol( 255, 255, 0))
pixel is transparent

If its 8bit then replace makecol( ...) with 0 I think.

I may be wrong.

miguel meza
Member #5,447
January 2005

thanks you, that was what i wanted......

Fladimir da Gorf
Member #1,565
October 2001
avatar

It's best to use bitmap_mask_color:

if( _getpixel( bitmap, x, y ) == bitmap_mask_color( bitmap ))

OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori)

Go to: