Log In  


I'm playing with P8 again and for my next game I'd need to get a pixel-perfect collision. Anyone got any samples of that?



https://www.lexaloffle.com/bbs/?tid=2170

https://www.lexaloffle.com/bbs/?tid=2179 (I like this one the best)

I've also seen another which I cannot find right now.


Thanks for trying to help, but both examples are testing collisions against either map or screen buffer.

I need collision test between two sprites that would disregard map or screen buffer data, a function perhaps that when called with sprite ids of the sprite to test against and sprite that is testing plus x/y of both (all sprites in my game are 8x8 so no worries there) and each sprite's transparent color (some of my sprites needs to use black as the color so have different transparent one).


This might be the other one that Matt was thinking of:
https://www.lexaloffle.com/bbs/?pid=20541#p20541


@darkhog your appraisal of at least one of the above links is incorrect :)

if you look carefully and read the text on the screen, https://www.lexaloffle.com/bbs/?tid=2179 shows pixel perfect collision between two sprites. the demo even shows you visually which pixels are colliding.

This is the result, a little demo that shows pixel (and basic box) collision feedback in real-time on a couple of sprites.

looking at the source it's even more obvious:

-- pixel-perfect collsion:
-- takes two sprite sheet 
-- numbers and a pixel offset
-- in x and y of the second
-- sprite from the first.
-- return true if any pixels in
-- sprites overlap, false
-- otherwise
function collide_pixel(sp1,sp2,xoff,yoff)

Must've missed it. Thanks for pointing it out!


You're welcome!



[Please log in to post a comment]