Saturday, 15 January 2011

Changing the Origin of a Animation in Python and Pygame -



Changing the Origin of a Animation in Python and Pygame -

i working on 2d platformer , sprites have animate bottom left point of animation , when draw animation using x , y point still animates bottom left, when draw animation screen sprite should shorter sprites feet lift of ground https://www.dropbox.com/s/ofeggmlcp4f6qsk/animation_probs_video.mp4 know video not high quality what. head should go , downwards not feet. if guy's can help me greatful. utilize programme fixes have linux computer windows xp virtual box , using python 2.7 , pygame. thanks.

assuming animating series of rectangular sprites each beingness instance of pygame.surface, adding difference between surface greatest height , current sprite's surface y position every time blit.

find height of tallest sprite once:

max_height = tallest_sprite.get_height()

now while cycling through sprints each frame current_sprite:

screen.blit(current_sprite, (x, y+(max_height - current_sprite.get_height())

if framerate issue, may want calculate these differences beforehand , associate them each sprite have 1 less get_height() phone call per frame.

python python-2.7 animation pygame

No comments:

Post a Comment