[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [pygame] Newbie help : Platforms and collisions
Hi,
On Samstag, Januar 4, 2003, at 09:59 Uhr, Fabrizio wrote:
I have troubles in making my hero standing on the platforms; it
"sinks" in the platforms more or less deeply according to the hero and
to the platform positions.
This sounds like the following Problem:
Frame n: Your Hero is just above a Platform.
Frame n+1: The Hero has fallen several pixels between the frames, and
is now "in" the platform. colliderect reports a hit.
The moment the Hero is just "on" the Platform is between frame n and
frame n+1. One solution would be to move the Hero to a position where
he stands correctly on the Platform when ever he hits a Platform.
Something like this:
# check if hero is on a platform
flag = 0
for t in pl_list :
#print t.pos,hero.pos,t.pos.colliderect(hero.pos)
if t.pos.colliderect(hero.pos) == 1 :
hero.pos.bottom = t.pos.top
hero.support = 1
flag = 1
if hero.s > 3 :
# if the jump is alraedy in the
#descending part then it
# stops jumping
hero.s = 0
j = 0
if flag == 0 :
# hero is not on a platform
hero.support = 0
if hero.support == 0 and j == 0:
# hero has support and is not jumping
hero.fall()
hero.move()
elif j == 1 :
#hero is jumping
hero.jump(dir)
else :
hero.move()
Thanks in advance for your help.
Hope it helps...
peter
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org