[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] New utility and library for pygame users in final BETA - simple support for multi-celled animation sheets - Tiallists needed.



On 22.02.2013 12:06, anthony.flury@xxxxxxxxxxxxxx wrote:
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.


Hi

Your idea is nice and I'm sure it works perfectly for grid based sprite sheets. Its simple and uses only one file.

In my opinion there are following cons:

  • many sprite sheets you can find might be grid base, but there are also many that are not (copy the images into a grid might work, but has it's drawbacks too)
  • if you have a separate file you could define your animation sequences reusing the same sprite over and over (example: you have a standing character image, that image you want to use in a walk, jump, idle animation, one image instead of copy it three times to each grid based sprite sheet, what if you have to change it?)
  • if the image offset is wrong in a grid based sprite sheet you need to move it in a image editor, but using a different file you just change a (magic) number
  • the image size limits are only set by the image edit, your (video) ram, your hardware speed

It would be useful if there would be a visual tool to generate the extra files and and a python module to facilitate the loading of such files and sprite sheets. I have given it myself some thoughts for some time now. I would be happy to elaborate.

~DR0ID