SuperSpriteSurface

SuperSpriteSurface is a class framework for REALbasic that provides a savvy, modern alternative to REALbasic’s built in SpriteSurface control. SuperSpriteSurface improves upon REALbasic’s built in SpriteSurface control (or ad hoc 2D solutions created with REALbasic’s Rb3D system) in several areas:

Graphics

SuperSpriteSurface uses OpenGL 2D functions to off load the graphics processing to the computer’s video card, resulting in the following benefits:

  • Fast compositing of both small and huge images (i.e., 1×1 to 2048×2048)
  • Storage of images in dedicated texture memory
  • Images can have 24 bit color depths (millions of colors) with 8 bits of alpha (256 levels of grey)
  • On-the-fly rotation, scaling and blending of images

Hundreds of sprites — at various sizes — animated

Collision Detection

Slick graphics aren’t worth much if you can’t create world that interacts with itself; that’s why extraordinary effort has gone into implementing a fast & robust collision detection system based on geometric bounding shapes. Multiple bounding shapes can be attached to your sprites at the same time, defining multiple “hit” regions. The types of bounding shapes that can be assigned include:

  • Point
  • Circle
  • Line
  • Rectangle
  • Convex Polygon

The collision system supports on-the-fly creation of collision sets (to limit the total number of shapes it has to cross check for collision). The system also caches pre-calculation collision results to further speed things up. Finally, when a collision occurs, the appropriate SuperSprite objects receive a collision event with details of the collision.

SuperSpriteSurface even supports a special debug mode which will overlay-draw your sprite’s collision shapes on top of your sprites — fine tune your game faster!

The collision tests demo running. Red shapes indicate a collision in progress.

Time-based Animation Controller

SuperSpriteSurface offers another important improvement over the built in SpriteSurface: the animation controller is time based, as opposed to frame based.

This time based animation controller will ensure that motion in your game or animation appears constant, no matter the speed of the target machine, the refresh rate of its monitor, the number of frames-per-second or the number of sprites that are on screen at once.

SuperSpriteSurface’s animation controller runs in hard-looped (speed) and threaded (cooperative) modes.

Multiple Sprite Types

SuperSpriteSurface includes two subclasses to the default SuperSprite sprite class: SuperSpriteGroup & SuperSpriteTile.

SuperSpriteGroup lets you create a hierarchy of sprite objects, similar to REALbasic’s built in Group2D class.

SuperSpriteTile offers similar functionality to the PaintTile event in the REALbasic SpriteSurface control: it lets you seamlessly tile small images, allowing you to create huge backdrops from a few source images. Because SuperSpriteTile is a SuperSprite subclass it may be transformed: moved, scaled & rotated, like any other SuperSprite object. You can also layer multiple SuperSpriteTile objects to create parallax scrolling effects!

SuperSpriteTile is fast — the class performs on-the-fly culling of the tiles that are not on screen and then draws only the tiles that are potentially visible.

The knights are are formed from a hierarchy of simpler sprites

The dungeon background is a SuperSpriteTile object made from thousands of tiles, but is optimized to draw only the visible portion — even under scaling and rotation transforms!

Text & Fonts

SuperSpriteSurface contains an OpenGL based text rendering engine. This text rendering engine is implemented as a subclass to the SuperSprite class, making it easy to use & integrate into your software. Since it’s a subclass of SuperSprite, it also supports rotation & scaling effects.

The text engine supports variable width fonts and font kerning for high quality text rendering. To give your text a bit of flair, the text engine will support 3 methods of coloring your text: simple color, gradient color, and full bit-mapped color.

SuperSpriteSurface includes an OS X-based font map creation tool, allowing developers to create SuperSpriteSurface Font Files that work & look identical cross-platform. Font Files are a combination of OpenGL texture maps and font glyph metrics data.

The Font Map Creation Tool will determine an optimal packing for the font image data, maximizing the texture space used. This tool will also allow you to export image templates to add texture or a 3d appearance to your font in an image editing program, if you so choose. When the user is done customizing the look of their font, the font creation tool will export the font images and font metrics in a single file that is easy to use within SuperSpriteSurface.

Many of the thousands of free fonts that are available on the internet are just perfect for games!

The Designer window of the Font Texture Creation Tool.

An Editing window from the Font Map Creation Tool. Edit the alpha & color data of your font file here or export image template for use in bit-mapped editing programs.

Sprite Behaviors & Mouse Interactivity

Among the new features added to version 2.0 are mouse events for SuperSprite objects and the SuperSpriteSurface control. This includes MouseDown, MouseDrag, & MouseUp, & built-in double-click support.

SuperSpriteSurface also supports the concept of behavior objects — reusable objects that you can attach to any SuperSprite. Behaviors receive copies of the same events that SuperSprite objects receive; they alter the SuperSprite object they are attached to in some way. Example behavior could be motion or physics based, such as calculating the trajectory of a mass and handling collision with other masses — or even mouse event based: controlling the behavior of an object when it is clicked or dragged.

Behaviors can be called automatically by the SuperSpriteSurface engine or you can explicitly control when they are executed — swapping or enabling behaviors on the fly.

The most powerful aspect of this system is that you can apply a behavior to any SuperSprite object, instantly giving any of your sprites added functionality while only maintaining a single class encapsulating the behavior!

The movie below shows mouse interactivity and behaviors in action: Cards are dragged around the window; double-clicking “flips” the card over. The drag behavior of the card is controlled by a reusable drag behavior that rotates the card to follow the cursor’s direction. In this example, the rotation caused by the generic drag behavior is able to be overridden by the parent SuperSprite when the shift key is held down.

Platform Support

SuperSpriteSurface supports Macintosh and Windows.

Documentation & Examples

SuperSpriteSurface includes API documentation* of the main control & classes, as well as an example project which contains several well-commented demos.

*The API documentation is current as of version 1.0 — I’d love it if a volunteer could help prepare an updated API reference!

Pricing & Availability

As of version 2.0, SuperSpriteSurface now costs nothing. The full project source is available for download and modification.

Download

zip SuperSpriteSurface 2 (2102 downloads since 2011-02-11)