Collision Detection (Ground & Slopes) in 2D Platform Game using Pygame Rects
- by RedCap
Hi,
First off, I am not after any instructions on logic for collision detection; I get it.
What I am trying to work out is the least complicated way to do this with Pygame using Sprites & Rects. I want to be able to check collisions for the Player against ground, walls & slopes. In theory it is quite straight forward, but I'm having difficulty because it seems like you cannot do this with one Rect.
One Rect is simple enough to get you collisions in the X plane against walls. The same Rect could be used also be used in the Y plane against solids, but not with slopes - since with the collision routines in Pygame it checks the whole Rect (or mask), rather than perhaps just the bottom middle of the Rect. It seems in addition you need to have a number of "sprites" to check collisions with, that are 1x1 pixel in various places around the Player.
What's the easiest way to do this, without having a bunch of 3, 4, or more separate "collision pixels" to check against slopes?
Geoff