Color collision
miguel meza

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

Pixel perfect collisions...
PixelMask or Ppcol.

miguel meza

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

isnt there a way to do what i want?

Fladimir da Gorf

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

miguel meza

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

SonShadowCat

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

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

Fladimir da Gorf

It's best to use bitmap_mask_color:

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

Thread #564579. Printed from Allegro.cc