GameUtils
For use with NPaintPro
Get it here: http://pastebin.com/2MMjiFjG
What is it?
GameUtils is a small API used for creating game entities that can be either sprites (static display) or animations (dynamic, updatable display). Game entities handle the internal information about where they are stored and drawn internally, so you only need to create them and place them for them to work, and be able to interact with each other. On the top level, you code will look like you're simply creating a few objects, placing them, and updating them with input or timers.
Behind the scenes, GameUtils is specifying their positions in world space, dynamically resizing their bounds and positions to fit with the sprite provided, even comparing individual bounds and pixels to let you know if your entities have collided. The API aims to encapsulate boilerplate code like collision detection and affine transformations without enforcing limitations on how the game objects can be used like a stricter game engine development environment. You're free to use the entities however you want, implement your own custom methods on how they work- it stays out of the way, so you can concentrate on the core mechanics of your game.
GameUtils was designed specifically as a companion API to NPaintPro, and leverages it's more advanced features like animation. Having said that, images made in the packaged Paint program, or any other programs that conform to its file format will also work. Visit http://www.computerc...-145-npaintpro/ for more information about NPaintPro.
What can I do with GameUtils?
- Import Paint, NFP or NFA files into your program
- Store the position of your sprite internally- it's collision detection and draw position will all be based off of the X and Y coordinates you specify
- Animate NFA sprites, either by changing frames manually or setting the upper and lower bounds of your animation and playing it through a timed loop
- Determine if sprites are colliding with one another, with rectangle or pixel precision
- Write to the screen buffer rather than using term calls to make your program buttery-smooth
What does GameUtils do for me?
- Dynamically resizes your sprites to eliminate whitespace- it doesn't matter where the sprite is on the canvas, GameUtils will make sure the top left corner is at (1,1)
- Creates an object with all pertinent functions relating to managing and updating your sprites
- Keeps track of active frames for animations and loops through them when updated
- Hides the more complicated calculations, so you can focus on making your game!
How do I use it?
Although GameUtils can save you a lot of time and effort in making your games, it does have quite a few rules to get your head around before starting. It is recommended you skim over the source code for the API (at least the comments) to get an idea of what functions are available to you and how to use them. A series of demonstration programs have been (or will be) developed to help show how to use some of the features GameUtils offers. They can be downloaded here:
Please post any questions, comments, feedback or bug reports as a reply to this topic. Enjoy!