Sunday, June 28, 2009

My ALLEGRO Sprite Class

One of the most unique things about developing with the ALLEGRO library is it's lack of a proper Sprite class. Instead, the library forces you to write your own. This can be very taxing task.

Over the course of the last three days, I've developed an extremely powerful, fleshed out Sprite class for use by people who develop with ALLEGRO like I do. I'm now offering it up for download by other ALLEGRO developers. All in all, this should probably knock about 6 - 10 hours off of your programming duties.

My Sprite Class has the following features:
  • Stores a single framed BITMAP to render
  • Stores a multi-framed BITMAP with each frame stored as a node in a linked list. Any node can then be rendered whenever the programmer desires
  • Render single or multi-framed BITMAPS with transformations
  • A Sprite can detect collision between itself and another Sprite
  • A Sprite can detect collision between itself and another object with an X, Y, Width, and Height value
  • Easily change a Sprite's Cartesian coordinates
  • Precise Frame tracking
While the Sprite class is very powerful, and all of it's features are working perfectly, it's by no means finished; It's simply finished enough. Theres still a lot of potential functionality I would like to add to it at a later date. In other words, updates to this project will eventually arrive.

To use the Sprite Class, simply place it's four source files (linkedlist.h, linkedlist.cpp, sprite.h, sprite.cpp) into where ever the rest of your source files for whatever you're working on go. You may wish to change the first line of actual code in linkedlist.h You will also need to add code in your projects' source files (#include "sprite.h") to properly link in my sprite class wherever necessary.

It should be noted that my Sprite class was developed and tested with ALLEGRO 4.2, but I believe it will work fine with older and newer versions of ALLEGRO, since only a small handful of the code actually uses stuff in ALLEGRO. To that end, I also believe it will work fine with the ALLEGRO port used by GBA Homebrew developers.

My Sprite Class is available for download by clicking here.

Legal information regarding the Sprite Class is below and included in the .rar I would appreciate if people would include the legal information regarding my Sprite Class in all distributions of programs which use it unless permission is given by me to do otherwise.

Creative Commons License
Arikado's ALLEGRO Sprite Class by Arikado is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.
Based on a work at arikadosblog.blogspot.com.
Permissions beyond the scope of this license may be available at http://arikadosblog.blogspot.com.

No comments:

Post a Comment