iDevGames Forums
Animation help in pygame - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Programming Languages & Scripting (/forum-8.html)
+--- Thread: Animation help in pygame (/thread-3424.html)



Animation help in pygame - suplexx - Mar 13, 2007 11:21 AM

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?


Animation help in pygame - Najdorf - Mar 13, 2007 12: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.)


Animation help in pygame - bronxbomber92 - Mar 13, 2007 01: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.
Code:
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 Wink


Animation help in pygame - suplexx - Mar 13, 2007 01:51 PM

thanks a lot for the replies guys

hopefully I wont bug you much anymore LOL