[All]
A Quick and Dirty VCL Sprite Engine
By: John Ray Thomas
Abstract: This article explains how to create a simple sprite engine with the VCL.
A Quick and Dirty VCL Sprite Engine
by JT
The VCL TBitmap and TCanvas components can provide a solid framework for a sprite engine.
TCanvas does a nice job encapsulating the Windows HDC and
it's associated drawing functionality and TBitmap provides easy to use
image management and transparency support.
A sprite engine has to do at least these things.
- Draw an image to a specific position and region.
- Draw a background image and foreground sprites without flicker.
- Allow a transparency color, to show the background around irregular shaped sprites.
- Move sprites to a new locations.
- Run through a series of images that comprise an animation cycle.
- Provide clipping against the world and other sprites.
A source code example can be downloaded from
CodeCentral.
It is a C++Builder 4 project but the source can be used with any version of C++Builder.
Here is a screenshot of the example application, "Tank".
Give it a test drive.
|
Connect with Us