This utility will be useful for anyone who writes games where they are 
creating muti-celled animations for their sprites, and would prefer to be 
able to easily record all the cells in one file for ease of use and 
editing. One problem with a multi-celled image file can be identifying 
where each cell is and extracting them from the files for use on your 
sprites in game.
 
You could either hardcode the layout of each mult-celled file into your 
game - leading to lots of magic numbers (and lots of potential for bugs), 
or have a separate sheet that sits along side your image file which 
desribes the position of each cell, and which your game reads at run time 
to extract the cells from the image.
 
Now there is another way - which does not need lots of embedded magic 
numbers, or separate files. Using my new command line tool and libary yyou 
can build and use multi-celled animation sheets easily. A single python 
module which is easy to integrate into your pygame applications - which 
works by recording the layout information wthin the multi-celled sheet, so 
it can be very easily read automatically. All you need to do to use my 
utility is 4 simple steps.
 
Step one : 
Use my tool to Create a single multi-celled sheet : 
 
Animsheet -a create -format=8,8 -size=32,32 troll.png 
 
*This will create a single image file with a pre-drawn 8x8 grid of 32x32 
boxes. Critically it also discretely saves the layout information in the 
same file, meaning my code can identify and read this file automatically - 
as you will see below.*
** 
Step two : 
Edit the sheet in your favourite image editor - use whatever you want - 
just draw your sprites inside the pre-drawn boxes.
 
Step three : 
Verify that your editing has not broken the stored data - this could happen 
by mistake so best to check .
 Animsheet -a verify troll.png 
 
*This will verify that the stored data is intact and can be read 
automatically - there is no need to store any of the information reported 
back - just check it is the same as when you created the file in step one.*
 
Step four :
In your code : 
 
import Animsheet # This is the same file as is executed for the command 
line.
...
multisheet = Animsheet()
multisheet.load("troll.png") # Loads the image file and automatically reads 
the layout (grid shape, cells size, gaps)
surfaces = multisheet.extract(surfaces.png) # Returns a list of surfaces 
one per cell
 
No more magic numbers in your code -, just slick python code to make your 
development job easier.
 
Pros : 
Full support for a variety of layouts and cell sizes - supports grids up to 
255x255 cells - and cells upto 255x255 pxels, variable backgrounds etc.
All data in one file - no more data files need to go along side your art 
work.
Simple to use within your python app, just 4 lines of code gets you all of 
your cells as surfaces ready to be drawn.
Save you time drawing and measuring the grids - just get on with the 
graphics.
No need for embedded magic numbers in your application - less magic, less 
chance of bugs.
 
Cons : 
I haven't found any yet :-).
 
If anyone is interested in being a beta trialist - please contact me 
through this group - thanks.

Reply via email to