Monday, August 2, 2010

The Sprite Module is Finished

The sprite module is finally finished, and I think it turned out well! The programmer can load up a single sprite sheet into a sprite batch class, and use the sprite batch class to instantiate a group of sprites to draw from that single texture.

Only one texture can be used for this class, but I may support a texture list per sprite if I can find a way to use it wisely... Maybe impose a 2-texture limit. I can still batch draw sprites, but I would have to use more draw calls to active multiple textures at once... Theoretically, I could very well draw an entire scene complete with the player, enemies, and props with a single texture batch object in a single draw call! This would be a good idea since I can retain the optimal performance I am currently getting by only using 1 texture if it is possible.

Another great idea would be to setup a quad map algorithm that divides static sprites up into a quadtree. Calculating the quadtree is slow, but it will make games that use this sprite lib extensively for 2D games render quickly by culling geometry.

Due to the way that SpriteBatch is designed to work and store its data, the quadmap would have to be its own class. What I would do is have my QuadMap class have a constructor that would take a list of SpriteBatch objects. All of that geometry would get consolidated into one giant structure, and sorted out spatially. Again, loading will be slow, so I would also add a function that would output the QuadMap's data into a serialized output file. Then, there would be another constructor that could load a QuadMap's data from a serialized binary file instead of from a group of pre-built SpriteBatch list. I think this would work just fine.

Before I do this, I'll have to finish a bunch of other stuff first such as cleaning up my Octree class, and getting it to process textures. I do not have the most confidence in this particular class. Another objective is to rewrite a new X file loader since the current one does has its limitations, and will cause crashes if the text is not in the correct format!

No comments:

Post a Comment