Right now, I have a collision detection in pygame which checks if two rctangles overlap or not...what I am trying to do is check the transparency of a the surface and if the alpha value is less then 10, stop player from walking into it..
Currently, Im doing this:
for i in range(0,self.rect.w):
for j in range(0,self.rect.h):
if player.rect.collidepoint((i,j)) and self.image.get_at((i,j))[3]<10:
#STOP PLAYER
But it is a real pain on the Processor. Is there another way to get the collision pixel coordinates in pygame??
Use
pygame.mask.Mask
objects andoverlap()
oroverlap_mask()
.overlap()
:overlap_mask()
:A mask can be created form a
pyame.Surface
withpygame.mask.from_surface()
-e.g.: