EscapeGranny_0.3 | Pixel Perfect collisions!


I've implemented pixel perfect collisions!

On the current version (0.2), I was relying on rectangles created by scratch. Rectangles are quite unreliable  due to it giving empty spaces around the sprite. It can make the player annoyed as they are for sure that they did not collide but it seems like it did.

I fixed this issue by learning about masks, masks are simply really damn useful for fast pixel perfect collision detection. If you are using a "png" file format for your images that you are importing, it is most likely that your image has transparency(alpha). With masks it can create a somewhat of an outline around your image by removing the alpha around the image creating an outline.

The legendary line that fixed the issue:

pygame.sprite.spritecollide(self, player, False, pygame.sprite.collide_mask)

BEFORE, this would kill you :
kekL collision 

Now that wont happen 😁

Files

EscapeGranny_0.3.zip 49 MB
Aug 14, 2021

Get EscapeGranny

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.