Was I wrong? The woes of collision detection

I don't know why it's so hard, but collision detection is being such a problem right now.  I had it working well except that you could walk into 1 block high areas... than I tried to fix that.  That's all I've done since about 9:15 this morning.  It's now 3PM and I am tired of messing around.  I'm guessing that it's because I'm trying to allow for entities of any size...  how do I get this to work?  I guess I'll limit myself to 1x1 block entities and 1x2 block characters... should help...

(log in to comment)


This has always been a problem in my Pyweek games. Really the only way I ever got it working was by fiddling around with the values until it felt good. Just keep thinking of simple solutions, and you'll eventually get it.

Another strategy is to calculate where the rectangles will be one frame in advance, and if they will be overlapping, adjust their velocity to move them right next to each other, but not colliding.
I've got it set pretty well, the only remaining bug is that when I jump up and hit a block I move to the right very quickly...  I'm uploading a demo now, if you feel like checking it out
Well it depends on what type of collision detection your using and how simple it is. For example, I myself would use:- "if blockxposition > wallxposition: blockxposition = wallxposition" Iknow its not really that smart but it works for me :D
Yep, CD is tricky. It doesn't seem like it would be but when you actually try it it turns out it is. Adjusting the scope of the game to fit whatever quirks your engine has is usually a good strategy when you find yourself in the midst of a surprise hangup.
@debarra I've got something a bit more complicated than that, considering my tiles are all Sprites, but I am still trying to make it simple

@saluk This particular quirk I'm at right now can't really be adapted around, whenever I jump up and hit a block, I go to the left if it's next to an air block, or to the right otherwise... really annoying.  I'll deal with it some other time, ragdolls await! (the physics of course)
if you are using a physics engine, then you should leave all the collision detection stuff to the physics library, rather than developing a pygame rect/sprite one, too.  i used box2d for last pyweek, and i'd love to show you how it works there, but i am probably one of a handful of people who can get it to work because of the complexities of box2d and the python bindings.