Python Pygame Tutorial - Pixel Perfect Collision Using Mask

preview_player
Показать описание
Thank you for watching my video and I really hope you found something useful.

In this episode we'll be exploring pixel perfect collisions using Pygame's mask functions and explaining a little bit about how it works.

The link the scripts and images in this video can be found here:

... and if you have any comments then feel free but bear in mind I don't pretend to be an expert, I just enjoying using Python and Pygame.

Anthony

Downloads:

Documents:

Рекомендации по теме
Комментарии
Автор

This one worked magic for me! I was using distance and rect collisions only! thanks!

Pakoaradillas
Автор

Thank you for this video I had trouble understanding what masks are by just reading through the docs!

mangaart
Автор

Hi, I just discovered your channel, very good videos there :)

What you should do for performance when using mask is:
-First check for a rectangle collision
-If there is one check masks
-else do nothing

yvonlegall
Автор

Outstanding stuff... Long time business programmer but wanted to dabble a bit in gaming and this content is really well done. Thanks for taking the time.

timw
Автор

How can I get the distance between the sprite and the mask's closest collision point?

tedsoderberg
Автор

Can I combine this with the sprites sheet class you did?

FiveMinuteGaming
Автор

Excellent videos. Thank you for your time and effort. It helped!!!!

nmgreg
Автор

Firstly great video :) secondly which quicker the rectangle collision detection or this one? thanks

duck-billedplatypus
Автор

How do I implement this into your sprite class? I don't quite get how to implement this anywhere else.

EDIT: You said somewhere about instead of creating a list of rectangles, to create a list of images. How would I go about doing that?

wengel_eth
Автор

thanks for the vid. is there a way to make a mask for a pygame.draw though? I have been searching for a bit but couldn't find any way to do it

hibob
Автор

Why do I get this error "argument 1 must be pygame.Surface, not pygame.Rect
"?

LakituStar
Автор

what does the convert_alpha in the obstacle variable do?

zeldafan
Автор

why your script in my computer not work
TypeError: integer argument expected, got float
please help me

lfuctqw
Автор

Obrigadão, my thanks for your very much

apamu
Автор

I got
AttributeError: 'pygame.mask.Mask' object has no attribute 'get_rect'

brendanchamberlain
Автор

Hi i m making collision simulator i want to do it without using vectors..but just plain maths and geometry

anandsuralkar
Автор

code.Pylet, one more question we can do a pixel perfect collision without the pos of mouse. So the move of player with keyboard

lfuctqw
Автор

thanks for the nice explanation. I also saw the sprite animation video which you made and was helpful. I've been looking for collision with animated sprites and this doesn't work for them as the sprite keeps changing ( as we store the sprites in a list and keep changing them). Can you help me with this?

RaviKiran-bkhw
Автор

Can I create a mask of a surface where it only masks one colour in the surface? And can I change the colour using the mask? I know this video is 3 years old but I hope someone answers

shinydewott