Collisions using masks between two images working at a specific point only | Pygame

  collision-detection, mask, overlap, pygame, python

I have tried to create a function that checks a collision between a static image, and one moving image. In the function, I attempted to create a mask of the moving image (The gun), and a mask of the balloons (static images) that are stored in a list and iterated over. Next, I made a rectangle around both of the images and checked where they overlap. When they overlap, it prints out collision with balloon #. The thing is, it only works at a certain position and doesn’t work for all of the balloons. Since you need images to run the code, you can run the code at this REPL.

Appreciate any help,
Thank you.

Source: Python Questions

LEAVE A COMMENT