Click here to Skip to main content
15,942,710 members
Articles / Multimedia / DirectX

Endogine sprite engine

Rate me:
Please Sign up or sign in to vote.
4.84/5 (53 votes)
17 Jul 200615 min read 727.2K   22.1K   216   121
Sprite engine for D3D and GDI+ (with several game examples).

Sample Image

Some of the examples are included in the source.


Endogine is a sprite and game engine, originally written in Macromedia Director to overcome the many limitations of its default sprite engine. I started working in my spare time on a C# version of the project about a year ago, and now it has far more features than the original - in fact, I've redesigned the architecture many times so it has little in common with the Director++ paradigm I tried to achieve. Moving away from those patterns has made the project much better. However, there are still a lot of things I want to implement before I can even call it a beta.

Some of the features are:

  • Easy media management.
  • Sprite hierarchy (parent/child relations, where children's Rotation, LOC etc. are inherited from the parent).
  • Behaviors.
  • Collision detection.
  • Plugin-based rendering (Direct3D, GDI+, Irrlicht is next).
  • Custom raster operations.
  • Procedural textures (Perlin/Wood/Marble/Plasma/others).
  • Particle systems.
  • Flash, Photoshop, and Director import (not scripts). NB: Only prototype functionality.
  • Mouse events by sprite (enter/leave/up/down etc. events).
  • Widgets (button, frame, window, scrollbar etc.). All are sprite-based, so blending/scaling/rotating works on widget elements as well.
  • Animator object (can animate almost any property of a sprite).
  • Interpolators (for generating smooth animations, color gradients etc.).
  • Sprite texts (each character is a sprite which can be animated, supports custom multicolor bitmap fonts and kerning).
  • Example game prototypes (Puzzle Bobble, Parallax Asteroids, Snooker/Minigolf, Cave Hunter).
  • IDE with scene graph, sprite/behavior editing, resource management, and debugging tools.
  • Simple scripting language, FlowScript, for animation and sound control.
  • Plug-in sound system (currently BASS or DirectSound).
  • New - Color editor toolset: Gradient, Painter-style HSB picker, Color swatches (supports .aco, .act, Painter.txt).
  • New - Classes for RGB, HSB, HSL, HWB, Lab, XYZ color spaces (with plug-in functionality). Picker that handles any 3-dimensional color space.

Sample Image

Some of the current GUI tools (editors, managers etc.).


I had been developing games professionally in Macromedia Director for 10 years, and was very disappointed with the development of the product the last 5 years. To make up for this, I wrote several graphical sub-systems, some very project-specific, but finally I designed one that fulfilled the more generic criteria I had for a 2D game creation graphics API. It was being developed in Director's scripting language Lingo from autumn 2004 to spring 2005, and since then it's a C# project..

It's a prototype

The current engine design is not carved in stone, and I have already made several major changes during its development, and even more are planned.

Optimizations will have to wait until all functionality is implemented. The GDI+ mode is extremely slow, because I haven't ported my dirty rect system yet. The D3D full-screen mode has the best performance.

The code is poorly commented at this stage, as it is still possible I'll rewrite many parts. If there is a demand for documentation, I will create it as questions appear. For now, you can get a feel for how to use it, by investigating the Tests project.

Example projects

There are two solutions in the download. One is the actual engine, including a project called Tests which contains most of the examples and code. I choose to include it in the solution since it's a little bit easier to develop/debug the engine if the test is part of it, but that's not the way your own projects should be set up. The MusicGame project is closer to how it should be done.

There's also a simple tutorial text on how to set up your own project.

I wanted to have a simple, but real-life testbed, so I'm creating a few game prototypes. Currently, they are Puzzle Bobble, a scrolling asteroid game, a golf/snooker game, CaveHunter, and Space Invaders. Other non-game tests are also available in the project. Turn them on and off by bringing the main window into focus and select items from the "Engine tests" menu.

Example walkthrough

Note: For using dialogs / editors, the Endogine.Editors.dll has to be present in the .exe folder. For sound, include Endogine.Audio.Bass.dll and the files in (shareware license).

To try out some of the examples in the Tests project, run the Tests solution and follow these steps:

  • Start in 3D/MDI mode (default).
  • Set focus on the Main window, so the Engine Tests menu appears in the MDI parent.
  • Select Particle System from the menu. The green "dialog" controls a few aspects of the particle system. The top slider is numParticles, the bottom the size. The buttons switch between color and size schemes. After playing around with it, turn it off by selecting Particle System again from the menu.
  • Select GDI+ random procedural, and also Font from the menu. This demonstrates a few ways to create procedural textures and manipulate bitmaps, as well as the support for bitmap fonts. Each letter sprite also has a behavior that makes it swing. Note that both are extremely slow - they're using my old systems. I'll upgrade them soon which will make them a hundred times faster.
  • Go to the SceneGraphViewer, and expand the nodes until you get to the Label sprite. Right-click it and select the Loc/Scale/Rot control. Try the different modes of changing the properties. Notice the mouse wrap-around feature.
  • Close the Loc/Scale/Rot control, go back to the SceneGraphViewer, expand the Label node. Right-click one of the letter sprites and select Properties (the LocY and Rotation properties are under the program control so they are hard to change here).
  • Click the Behaviors button to see which behaviors the sprite has. Mark ThisMovie.BhSwing, and click Remove to make it stop swinging. (Add... and Properties... aren't implemented yet).
  • Stop the program, and start it again, but now deselect MDI mode (because of .NET's keyboard problems in MDI mode).
  • Set focus to the Main window and select Puzzle Bobble from the menu. Player 1 uses the arrow keys to steer (Down to shoot, Up to center), player 2 uses AWSD. Select it again to turn it off. Note: due to changes in the ERectangle(F) classes, there's currently a bug which makes the ball stick in the wrong places. Will look into that later. (May be fixed.)
  • Select Snooker from the menu and click-drag on the white ball to shoot it. Open the Property Inspector for the topology sprite object, change Depth and Function to see how a new image is generated, use the Loc/Scale/Rot control to drag it around, and see how the balls react (buggy, sometimes!).
  • Select Parallax Scroll from the menu and try the Asteroids-like game. Arrow keys to steer, Space to shoot. Note: the Camera control's LOC won't work now, because the camera is managed by the player, centering the camera over the ship for each frame update. That's how the parallax works - just move the camera, and the parallax layers will automatically create the depth effect.
  • (Broken in the Feb '06 version) Go to the main menu, Edit, check Onscreen sprite edit, and right-click on a sprite on the screen, and you'll get a menu with the sprites under the mouse LOC. Select one of the sprites, and it should appear as selected in the SceneGraph. It doesn't update properly now, so you'll have to click the SceneGraph's toolbar to see the selection.

Using the code

Prerequisites: .NET 2.0 and DirectX 9.0c with Managed Extensions (Feb 06) for the demo executable, and DirectX SDK Feb 06 for compiling the source. You can download SharpDevelop 2.0 or Microsoft's Visual Studio Express C# for free, if you need a C# developer IDE. Read the README.txt included in the source for further instructions.

Note that Managed DirectX versions aren't backwards nor forwards compatible. I think later versions will work if you recompile the project, but the demo executable needs MDX Feb 06.

I'm currently redesigning the workflow, and you would need a fairly long list of instructions in order to set up a new solution which uses Endogine, which I haven't written. The easiest way to get started is by looking at the Tests project. You can also have a look at the MusicGame solution, which is more like how a real project would be organized.

Most of the terminology is borrowed from Director. Some examples of sprite creation:

Sprite sp1 = new Sprite();
//Loads the first bitmap file named 
//Ball.* from the default directory
sp1.MemberName = "Ball";
sp1.Loc = new Point(30,30); //moves the sprite

Sprite sp2 = new Sprite();
//If it's an animated gif, 
//the sprite will automatically animate
sp2.MemberName = "GifAnim";
sp2.Animator.StepSize = 0.1; //set the animation speed
sp2.Rect = new RectangleF(50,50,200,200); //stretches and moves the sprite

Sprite sp2Child = new Sprite();
//same texture/bitmap as sp1's will be used 
//- no duplicate memory areas
sp2Child.MemberName = "Ball";
//now, sp2Child will follow sp2's location, 
//rotation, and stretching
sp2Child.Parent = sp2;

Road map

I'll be using the engine for some commercial projects this year. This means I'll concentrate all features that are necessary for those games, and that I probably won't work on polishing the "common" feature set a lot.

There will be a number of updates during the year, but I've revised my 1.0 ETA to late autumn '06. I expect the projects to put an evolutionary pressure on the engine, forcing refactoring and new usage patterns, but resulting in a much better architecture. Another side effect is documentation; I'll have to write at least a few tutorials for the other team members.

Currently, I put most of my spare time into PaintLab, an image editor, which is based on OpenBlackBox, an open source modular signal processing framework. They both use Endogine as their graphics core, and many GUI elements are Endogine editors, so it's common that I need to improve/add stuff in Endogine while working on them.

Goals for next update (unchanged)

I've started using Subversion for source control, which will make it easier to assemble new versions for posting, so updates with new tutorials and bug-fixes should appear more often. Some probable tasks for the next few months:

  • Switch between IDE/MDI mode and "clean" mode in runtime.
  • Clean up terminology, duplicate systems, continue transition to .NET 2.0.
  • Look into supporting XAML, harmonize with its terminology and patterns.
  • Fix IDE GUI, work on some more editors.


Update 2006-07-06

Again, other projects have taken most of my time - currently it's the OpenBlackBox/Endogine-based PaintLab paint program. Side effects for Endogine:

  • Color management tools: editors, color space converters, color palette file filters etc.
  • Refactoring: WinForms elements are being moved out of the main project into a separate DLL. Simplifies porting to mono or WPF, and makes the core DLL 50% smaller.
  • Improved Canvas, Vector3, Vector4, and Matrix4 classes.
  • Improved PSD parser.
  • More collision/intersection detection algorithms.
  • Several new or updated user controls.

Update 2006-03-15

I've focused on releasing the first version of OpenBlackBox, so most of the modifications have been made in order to provide interop functionality (OBB highly dependent on Endogine).

  • Optimizations (can be many times faster when lots of vertices are involved).
  • Continued transition to .NET 2.0.
  • Requires DirectX SDK Feb '06.
  • Simple support for HLSL shaders and RenderToTexture.
  • Better proxies for pixel manipulation - Canvas and PixelDataProvider classes instead of the old PixelManipulator.
  • Extended interfaces to the rendering parts of Endogine. Projects (such as OpenBlackBox) can take advantage of the abstracted rendering API without necessarily firing up the whole Endogine sprite system.
  • Forgot to mention it last time, but there's a small tutorial included since the last update.

That's pretty much it. But don't miss OpenBlackBox, in time it will become a very useful component for developing applications with Endogine!

Update 2006-02-01

Some major architectural changes in this version, especially in the textures/bitmap/animation system. The transition isn't complete yet, so several usage patterns can co-exist and cause some confusion. Some utilities will be needed to make the animation system easier to use.

  • Moved to .NET 2.0. Note: refactoring is still in progress (e.g., generics isn't used everywhere yet).
  • The Isometric example has been removed. I've continued to work on it as a separate project, which I'll make available later if possible.
  • Renderers are now plug-ins, allowing for easier development/deployment. (Also started on a Tao- based OpenGL renderer, but lost my temper with its API.)
  • PixelManipulator - easy access to pixels regardless of if the source is a bitmap or texture surface.
  • Examples of how to use the PixelManipulator (adapted Smoke and Cellular Automata3 from - thanks Mike Davis and Glen Murphy for letting me use them).
  • C# version of Carlos J. Quintero's VB.NET TriStateTreeView - thanks Carlos. Added a TriStateTreeNode class.
  • Started on a plugin-based sound system. Currently, I've implemented two sound sub-systems: BASS and a simple DirectX player. OpenAL can be done, but BASS is cross-platform enough, and it has a better feature set. Later, I'll add DirectShow support.
  • Included a modified version of Leslie Sanford's MidiToolKit (supports multiple playbacks and has a slightly different messaging system). Thanks!
  • Flash parser/renderer has been restructured and improved. Can render basic shapes and animations.
  • System for managing file system and settings for different configurations (a bit like app.config but easier to use and better for my purposes).
  • RegEx-based file finder (extended search mechanism so you can use non-regex counters like [39-80] and [1-130pad:3] - the latter will find the string 001 to 130).
  • Helper for creating packed textures (tree map packing).
  • Abstraction layer for texture usage - the user doesn't have to care if a sprite's image comes from a packed texture or not.
  • The concept of Members is on its way out, replaced by PicRefs. Macromedia Director terminology in general will disappear over time from now on.
  • New, more abstracted animation system. Not fully implemented.
  • .NET scripting system with code injection. Currently only implemented for Boo, but will support other languages. Will be restructured later, with a strategy pattern for the different languages.
  • New vastly improved bitmap font system, both for rendering and creating fonts. Real-time kerning instead of precalculated kerning tables.
  • Localization/translation helper (for multi-language products).
  • A number of helper classes such as the IntervalString class (translates "-1-3,5-7" to and from the array [-1,0,1,2,3,5,6,7]).
  • Unknown number of bug fixes and optimizations.

Update 2005-10-10

Since the last update wasn't that exciting from a gaming POV, I decided to throw in a new version with a prototype isometric game. Totally R.A.D.

  • Isometric rendering, based on David Skoglund's game CrunchTime, including his graphics (see _readme.txt in the Isometric folder). Thanks, pal!
  • A Star pathfinding algorithm adapted from an implementation by John Kenedy. Thank you!
  • Removed references to LiveInterface.
  • Added "resource fork" for bitmap files - an XML file with additional info such as number of animation frames and offset point.

Update 2005-10-04

OK, it's over a month late, and it doesn't include stuff you might have been waiting for, and the things I've been working on - mainly creating two script languages - aren't that useful in their current state (especially with no good examples of their use). I think it was worth putting some time into, as I'm certain FlowScript will become a great tool later on. Here's what I've got for this version:

  • Compiled using the August 2005 SDK.
  • Added Space Invaders prototype.
  • Added curves rendering to .swf import (it still renders strange images).
  • Reorganized the engine into a .dll.
  • Fixed mouse LOC <-> screen LOC error.
  • Fixed transparency / alpha / color-key issues.
  • Map (probably a bad name) class - like a SortedList, but accepts multiple identical "keys".
  • Node class, like XmlNode, but for non-text data.
  • Started preparing the use of 3D matrices for scale/LOC/rotation.
  • Removed DirectDraw support.
  • Basic sound support.
  • A badly sync'ed drum machine example.
  • FlowScript, a time-based scripting language, aimed at non-programmers for animation and sound control, based on:
  • EScript, simple scripting language based on reflection (no bytecode).
  • Simple CheckBox widget.

Update 2005-08-01

  • Compiled using the June 2005 SDK.
  • Sprite.Cursor property (works like Control.Cursor).
  • Simple XML editor.
  • .NET standardized serializing.
  • PropertyGrid instead of custom property editors.
  • VersatileDataGrid User Control (a new DataGrid control which implements functionality missing in .NET's standard DataGrid).
  • TreeGrid User Control - a bit like Explorer, but the right-hand pane is a VersatileDataGrid locked to the treeview.
  • Two new game prototypes: CaveHunter and Snooker/MiniGolf.
  • ResourceManager editor w/ drag 'n' drop to scene (and to SceneGraph viewer).
  • Better structure.
  • Transformer behavior - Photoshop-style sprite overlay for moving/scaling/rotating.
  • Scene XML import/export.
  • Director Xtra for exporting movies to Endogine XML scene format.
  • Import Photoshop documents - each layer becomes a sprite, layer effects become behaviors. Decoding of layer bitmaps incomplete.
  • Import Flash swf files (rendering code incomplete).
  • BinaryReverseReader which reads bytes in reverse order (for .psd), and BinaryFlashReader which reads data with sub-byte precision (for .swf).
  • Extended EPoint(F) and ERectangle(F) classes. Note that Puzzle Bobble doesn't work properly after the latest changes, I'll take care of that later.

Update 2005-07-07

  • Camera node.
  • Parallax layers.
  • LOC/Scale control toolbox.
  • User Controls: ValueEdit (arrow keys to change a Point), JogShuttle (mouse drag to change a Point value by jog or shuttle method).
  • MDI mode crash fixed (thanks to adrian cirstei) - but keys still don't work in MDI mode.
  • Multiple Scene Graph windows.
  • Select sprites directly in scene.
  • Asteroids-type game with parallax layers.
  • Extended EPoint(F) and ERectangle(F) classes.

Update 2005-06-27

  • Optional MDI interface: editors and game window as MDI windows. (Problem: I get an error when trying to create the 3D device in a MDI window.)
  • Scene Graph: treeview of all sprites.
  • Sprite marker: creates a marker around the sprite which is selected in the scene graph.
  • Property Inspector: interface for viewing and editing sprite properties.
  • Sprite Behaviors: easy way to add functionality to sprites. The swinging letters animation is done with a behavior.
  • Behavior Inspector: add/remove/edit behaviors in runtime.
  • Inks use an enumeration instead of an int (ROPs.Multiply instead of 103).
  • Switched from MS' too simplistic Point(F)/Rectangle(F) classes to my own EPoint(F)/ERectangle(F), which have operator overloading and many more methods. Note that I've chosen to write them as classes, not structs - i.e., they're passed as references, not values.
  • Easier keyboard handling (assigns names to keys - makes it easier to let the user define keys, or to have multiple players on one keyboard).
  • Puzzle Bobble allows multiple players in each area.

You can read about my early thoughts about the Endogine concept, future plans, and see some Shockwave/Lingo demos here.

I have added a Endogine C# specific page here, but it probably lags behind this page.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Written By
Web Developer
Sweden Sweden
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

QuestionCan't download .zip file; redirection to some strange workspace page where "file doesn't exist" here is likely ... Pin
RedDk16-Apr-14 7:05
RedDk16-Apr-14 7:05 
QuestionSupport for MonoDevelop / Linux? Pin
Andreas Hennings13-Sep-11 4:12
Andreas Hennings13-Sep-11 4:12 
AnswerRe: Support for MonoDevelop / Linux? Pin
Andreas Hennings13-Sep-11 4:53
Andreas Hennings13-Sep-11 4:53 
AnswerRe: Support for MonoDevelop / Linux? Pin
Andreas Hennings13-Sep-11 5:06
Andreas Hennings13-Sep-11 5:06 
GeneralManaged DirectX Pin
tobias00430-May-10 2:45
tobias00430-May-10 2:45 
Questionare you still working on this project? Pin
Member 7932521-Sep-09 16:37
Member 7932521-Sep-09 16:37 
GeneralMemory Error In Particle System Pin
Reelix12-Mar-09 20:22
Reelix12-Mar-09 20:22 
GeneralRe: Memory Error In Particle System Pin
Jonas Beckeman12-Mar-09 23:01
Jonas Beckeman12-Mar-09 23:01 
GeneralRe: Memory Error In Particle System Pin
Reelix12-Mar-09 23:09
Reelix12-Mar-09 23:09 
GeneralRe: Memory Error In Particle System Pin
Jonas Beckeman12-Mar-09 23:13
Jonas Beckeman12-Mar-09 23:13 
GeneralRe: Memory Error In Particle System Pin
Reelix12-Mar-09 23:20
Reelix12-Mar-09 23:20 
GeneralRe: Memory Error In Particle System Pin
Jonas Beckeman12-Mar-09 23:29
Jonas Beckeman12-Mar-09 23:29 
GeneralRe: Memory Error In Particle System Pin
Reelix12-Mar-09 23:37
Reelix12-Mar-09 23:37 
GeneralContinued Pin
tobias00412-Mar-09 6:54
tobias00412-Mar-09 6:54 
GeneralRe: Continued Pin
Jonas Beckeman12-Mar-09 8:30
Jonas Beckeman12-Mar-09 8:30 
GeneralRe: Continued Pin
tobias00412-Mar-09 10:24
tobias00412-Mar-09 10:24 
Question"Exception has been thrown by the target of an invocation." Error Pin
Wan--Vevi17-Jul-08 23:24
Wan--Vevi17-Jul-08 23:24 
QuestionHow to clear screen? Pin
Megalan9-Jul-08 4:46
Megalan9-Jul-08 4:46 
AnswerRe: How to clear screen? Pin
Jonas Beckeman9-Jul-08 6:28
Jonas Beckeman9-Jul-08 6:28 
GeneralRe: How to clear screen? Pin
Megalan9-Jul-08 7:29
Megalan9-Jul-08 7:29 
GeneralRe: How to clear screen? Pin
Jonas Beckeman9-Jul-08 12:00
Jonas Beckeman9-Jul-08 12:00 
GeneralRe: How to clear screen? [modified] Pin
Megalan9-Jul-08 23:08
Megalan9-Jul-08 23:08 
GeneralRe: How to clear screen? Pin
Jonas Beckeman10-Jul-08 1:42
Jonas Beckeman10-Jul-08 1:42 
GeneralRe: How to clear screen? [modified] Pin
Megalan10-Jul-08 2:20
Megalan10-Jul-08 2:20 
GeneralDisplaying JPG image bytes on the form using Direct X Pin
sraddhan28-Feb-08 19:32
sraddhan28-Feb-08 19:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.