PDA

View Full Version : Animation help in pygame


suplexx
2007.03.13, 03:21 PM
I am trying to learn python/pygame and I've ran into a problem. Is it possible to use a spritesheet to simulate walking? I can move the sprite around but it's just like he's sliding around. I'm sorry if I didn't explain in detail, but perhaps someone could help me with this?

Najdorf
2007.03.13, 04:43 PM
You should do both, moving the sprite's coordinates and changing the sprite's picture (so he appears to be moving legs etc.)

bronxbomber92
2007.03.13, 05:14 PM
You can use time based animation or frame based animation.

Say you have an array (tables in python?) of each image names 'images' and a timer called 'timer', this is what the psudeo code would look like.
while left is being pressed
if timer.time >= 0 && timer.time <=4 then
blit images[0]
end

if timer.time >= 5 && timer.time <=9 then
blit image[1]
end

if timer.time >= 10 && timer.time <=14
blit image[2]
end
end That's very basic way to do animations and not the best, but you should get the idea ;)

suplexx
2007.03.13, 05:51 PM
thanks a lot for the replies guys

hopefully I wont bug you much anymore :lol: