This project generates Sprite Maps and meta-data to go with from 3D->2D conversion. The goal is to allow sprites to be generated in a variety of ways, but my current endeavours only require 3D->2D sprites. These sprite maps can then be loaded and used in 2D games written in any language.
I have provided a simple loader and animation class structure for use in C# and XNA that can be ported to other languages: https://bitbucket.org/jcpmcdonald/xna-sprite-lib
This uses the Microsoft Public Licence (MS-PL)
What makes up a Sprite?
For the purpose of this project, I have defined the following:
- A Sprite is the collection of Sequences that represent a Game Element
- A Game Element is a visual element in the game-world
- A Sequence is a collection of ordered Frames
- A Frame is a rectangular section of an image
That is to say that menu items, HUDs, buttons, text, loading screens, all of that is not a Sprite because they do not exist in the game-world.
Also, each Sequence has a unique combination of Set, Animation, and Rotation where:
- A Set indicates the set of the sprite to use. This can be used for a second, complete set of Sequences for the sprite. Examples are: (full health, half health, and almost dead) or (sword, vs spear).
- An Animation represents an action that the sprite is doing. Examples are: Idle, Walking, and Jumping
- An Orientation represents the direction the sprite is facing. Examples are: (left and right) or (0, 45, 90, 135, 180, 225, 270, and 315 degrees)
Any of the above can be left as "Default" if they aren't useful for your application. Every frame can be accessed by using a 4-dimensional array like so:
Where the frame# indicates the progress through the sequence. When the Animation changes, the Frame counter restarts at 0. When the Set or Orientation changes, the Animation and Frame counters do not change, the current animation just continues in the new set or orientation. Each Animation indicates which Animation should follow, once completed. For a looping animation, the animation will refer to itself. For a ping-pong animation, there will be a second animation that uses the same set of frames, only in reverse. And for animations continuing on to greater things, they point elsewhere. Whenever an animation completes, either a flag will be set to indicate this, or an event will get fired to allow the game to take any required actions (like start moving after standing up).