'How to check if a rectangle "completely" collides with a sprite class
I'm trying to write a game where the player has to remain on the generated rectangles which are constantly moving to the left. The player loses if their character leaves the frame. here is what the game looks like
here is the collision detection I am currently using in my player sprite class.
if pyg.sprite.spritecollide(player.sprite, path_group, False):
self.move()
else:
self.rect.x -= 2
The problem is that instead of stopping the player when they collide, it just lets the player leave the path, and disables the control after they're completely stuck outside of it. Is there a better way to detect collisions here? (the "path_group" is a group of sprites which represent the path. Not what is "not the path"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
