[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Strategies for platformers



Hi,

> so a jump "pattern" might look something like this in the y direction:
> [4,2,1,0,-1,-2,4] ? Am I following you correctly?

Yes. Of course the last member is -4.

If you want pixel-by-pixel movement, the above list become :
[1,1,1,1,1,1,1,0,-1,-1,-1,-1,-1,-1,-1]

that is :
7*[1] + 7*[-1]

> What are the pros and cons of this strategy?

This is what I would like to know from you !
As I see it, the advantage is that it is quite easy to develop a complicated
pattern for enemies; e.g. one character might move at first up and down, and
then left and right :

speedX =[0,0,0,0,5,5,-5,-5]
speedY =[5,5,-5,-5,0,0,0,0]

and you can even think about much more complicated patterns.


> This is one approach I've seen discussed before.  On the mailing list
> look for the subject "Smooth animation".  I don't know if a conclusion
> was ever reached, though.

Thanks for the info. I have found that thread and got some ideas; but I
still do not get it.
And what is your approach on this issue ?


> > 2- How to stop jumping when hero is landing on a platform coming from
the
> > bottom. I did this by checking if the jump is in the "descending" part
and
> > then stopping jumping only in this case.
>
> Could you explain this problem better? I don't understand.

I mean that if the hero jumps from the bottom of a platform (see below) it
does not have to stop jumping immediately as it detect a collision with the
platform. Instead, it has to continue its jumping and "land" onto the
platform.

>
> > 3 - How to avoid collision detection for "transparent" pixels (= use of
> > colorkey).
>
> My approach here is to give a sprite an extra rectangle (call it
> solidRect) that corresponds roughly to the opaque parts of the image,
> and when I'm checking for collisions, I don't use mySprite.rect, I use
> mySprite.solidRect instead.

Interesting. Any better ways ?


> > 4 - How to avoid collisions with platforms when hero jumps from the
bottom.
> > I did this by setting up an "upper edge" rect (for platforms) and a
"bottom
> > edge" rect (for hero) and detecting collision on this "edges" instead of
on
> > the full "sprite" rect. This approach does not work fine if movement is
more
> > than one pixel per frame, as collision might occur "between frame".
>
> So you want the charactor to 'bump his head' on platforms above him when
> he jumps into them?  Or to pass right through them on the way up?

Pass through and land on the upper part of the platform (e.g. "Manic Miner
style")


cheers,

Fabrizio


____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org