Log In  
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?

P#21904 2016-05-31 08:06 ( Edited 2016-05-31 20:56)

:: matt

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.

P#21909 2016-05-31 09:28 ( Edited 2016-05-31 20:43)

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).

P#21925 2016-05-31 15:18 ( Edited 2016-05-31 19:18)

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

P#21929 2016-05-31 15:26 ( Edited 2016-05-31 19:26)
:: matt

@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)
P#21944 2016-05-31 16:44 ( Edited 2016-05-31 20:56)

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

P#21945 2016-05-31 16:55 ( Edited 2016-05-31 20:55)
:: matt

You're welcome!

P#21946 2016-05-31 16:56 ( Edited 2016-05-31 20:56)

[Please log in to post a comment]

X
About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-03-22 12:08 | 0.014s | 2097k | Q:22