Original Post
Hey guys! I posted here yesterday, and it led me to a solution, so I'd like your help again. Now, I'm really going crazy with this, I can't even think properly. My problem is, I'm making a platformer and I'm having a *hard* time getting the collision detection right. What I want is, platforms are bypassable from the bottom and the side, but if you jump through them and your legs are on top of it, they 'become solid'. I spent hours trying, no solution so far. Here is the code:
Help is very much appreciated, thanks for reading!
# This is a part of the Avatar class, which has a map in self.map which has platforms (their pygame.rect's) in it.
for platform in self.map.platforms:
left = self.rect.x
right = self.rect.x + self.rect.w
top = self.rect.y
bottom = self.rect.y + self.rect.h
platformLeft = platform.rect.x
platformRight = platform.rect.x + platform.rect.w
platformTop = platform.rect.y
platformBottom = platform.rect.y + platform.rect.h
# If there is a collision
if (bottom >= platformTop) and \
(top <= platformBottom) and \
(right >= platformLeft) and \
(left <= platformRight):
pass
# NO IDEA <img src='http://public.gamedev.net//public/style_emoticons/<#EMO_DIR#>/sad.png' class='bbc_emoticon' alt=':(' />
Help is very much appreciated, thanks for reading!