TurtleBrains  0.3.1
High quality, portable, C++ framework for rapid 2D game development.
Sprite Sheets

It is quite possible to create sprites and animations programmatically, but like other portions of TurtleBrains the heart of quick iterations is with data driven design. As of v0.3.1 .json is the only supported format, though there is no reason similar structured formats, like .xml, could be used in the future.

At a bare minimum the sprite sheet must contain a string object, texture, that contains the path, relative to where the executable runs, to the image used for each sprite, AND an array of objects that describe each sprite frame:


    "texture" : "data/castle.png",
    "sprites" : [
        {   "name":"moat", "x":0, "y":0, "width":100, "height":100 },
        {   "name":"bridge", "x":100, "y":0, "width":100, "height":100 },
        {   "name":"flag", "x":200, "y":0, "width":50, "height":50 },
        {   "name":"tower", "x":0, "y":100, "width":100, "height":200 },
        {   "name":"gate", "x":100, "y":100, "width":200, "height":200 }

Each sprite object must contain a name that is unique to all others on the same sprite sheet, an x,y coordinate for the top-left pixel location on the texture/image and the width/height in pixel-space on that image. From there it gets a little more advanced. The sprite objects may contain an array of animations.

TODO: TurtleBrains: Documentation: Continue writing about the various forms of animation sequence structures.