We shall detect the collision of the cannons (circle sprites) with the rocket sprite and detect a problem that we would face.
This must be done before the display update.
#sprite collide is for sprites in a group for circle in wall_group: if(rocket.rect.colliderect(circle.rect)): print("collision : " + str(id(circle))) #wall_group.remove(circle) #wall_group.draw(SCREEN) pygame.display.update()
If you run this code, the rocket shows collision nowhere near the cannon, the rectangle we got from the circles is huge, that is why.
I tried to get this to work, but failed.
The other methods:
- The cannons need not be sprites but normal python objects
- Secondly, use images for cannons instead of drawing circles in the sprite