The Python Game Book

code games. learn Python.

User Tools

Site Tools


en:part2:pygame:step008

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:part2:pygame:step008 [2011/05/13 08:46]
horst [source code]
en:part2:pygame:step008 [2011/11/04 06:43]
imapiekindaguy
Line 1: Line 1:
 ^ [[:en:part2:pygame:step007| ← previous]] ^ [[en:part2:pygame:start| ↑ Overview]] ^ [[:en:part2:pygame:step009| → next ]] ^ ^ [[:en:part2:pygame:step007| ← previous]] ^ [[en:part2:pygame:start| ↑ Overview]] ^ [[:en:part2:pygame:step009| → next ]] ^
-====== step 008 - animation ======+====== Step 008 - Animation ======
  
 Remember the Subsurfaces from the last step? And remember that the snake had always the same grinning facial expression? Now, let's make some animated **sprites**((a 2d-object moving around is referred as a [[wp>Sprite_(computer_graphics)]])) - not pygame sprites, but surfaces that show different images of an animation cycle, like a bird flapping its wings. Remember the Subsurfaces from the last step? And remember that the snake had always the same grinning facial expression? Now, let's make some animated **sprites**((a 2d-object moving around is referred as a [[wp>Sprite_(computer_graphics)]])) - not pygame sprites, but surfaces that show different images of an animation cycle, like a bird flapping its wings.
  
 {{ :en:part2:spritesheet008.jpg?300|}} {{ :en:part2:spritesheet008.jpg?300|}}
-Instead of painting all the single pictures of an animation cycle myself I prefer to use ready-made sprite sheets.+Instead of painting all the single pictures of an animation cycle myselfI prefer to use ready-made sprite sheets.
  
-In the data folder, you will find a spritesheet((a graphic file with lots of sprites)) from Ari Feldmann Spritelib ( http://www.flyingyogi.com ) showing several pictures of an animal. If you use Ari's sprite's, make sure to include his [[:en:resources:glossary:s:spritelib_license|license information]] in your program.+In the data folder, you will find a spritesheet((a graphic file with lots of sprites)) from Ari Feldmann'Spritelib ( http://www.flyingyogi.com ) showing several pictures of an animal. If you use Ari's sprite's, make sure to include his [[:en:resources:glossary:s:spritelib_license|license information]] in your program.
  
 With the help of pygame's subsurface command, I will show you how to extract single images from the sprite sheet and use them. With the help of pygame's subsurface command, I will show you how to extract single images from the sprite sheet and use them.
  
  
-==== discussion ====+==== Code Discussion ====
  
  
Line 19: Line 19:
  
  
-==== additional resources ==== + 
-{{:en:part2:data008.tar.gz|}} +===== Source Code on Github =====
-===== source code on github =====+
  
 To run this example you need: To run this example you need:
  
 ^  file  ^  in folder  ^  download  ^ ^  file  ^  in folder  ^  download  ^
-|  [[https://github.com/horstjens/ThePythonGameBook/raw/master/pygame/008_animation.py|008_animation.py]]  |  pygame  |  Download the whole Archive with all files from Github:  \\  https://github.com/horstjens/ThePythonGameBook/archives/master  |+|  [[https://github.com/horstjens/ThePythonGameBook/raw/master/pygame/008_animation.py|008_animation.py]]  |  ''pygame''   Download the whole Archive with all files from Github:  \\  https://github.com/horstjens/ThePythonGameBook/archives/master  | 
 +|  [[https://github.com/horstjens/ThePythonGameBook/blob/master/pygame/data/char9.bmp|char9.bmp]] \\ [[https://github.com/horstjens/ThePythonGameBook/blob/master/pygame/data/char9.bmp|{{:en:part2:pygame:char9_150.jpg|Sprite sheet by Ari Feldman}}]]  |  ''pygame/data''  |  :::  |
  
  
Line 37: Line 37:
  
  
 +====== Comment this Page ====== 
 +~~DISQUS~~
  
 ^ [[:en:part2:pygame:step007| ← previous]] ^ [[en:part2:pygame:start| ↑ Overview]] ^ [[:en:part2:pygame:step009| → next ]] ^ ^ [[:en:part2:pygame:step007| ← previous]] ^ [[en:part2:pygame:start| ↑ Overview]] ^ [[:en:part2:pygame:step009| → next ]] ^