Documentation for the Graphics Magician Direct Express library, 2005/2008 editions

Starting a Graphics Magician project

After you've successfully created and run the test project above, take your time exploring all the tools available with the Graphics Magician. There are seven basic objects. The GMMachine object is the basis for all the others. The rest of the objects let you do fancy things with graphics, animation, and sound.

GMMachine

This is the basic "machine" needed by all the other objects. This object encapsulates many of the DirectDraw, DirectInput, DirectSound, Direct3D, and MIDI multimedia capabilities, as well as the essentials required to create a Win32 executable program. All programs that use the Graphics Magician will create one GMMachine object on startup. This makes DirectX programs for Windows as easy to program as C++ console applications, but it also gives you the full capabilities of DirectX for fast animation and interaction with the machine.

GMBitmap

This object contains bitmap information and can display them onto screens of the Graphics Machine. Use a GMBitmap object for every bitmap (picture, image, or icon) in your program. Animated images (those with multiple frames) will have a GMBitmap object for each frame of the image. (In DirectX terminology, this is also known as a "Surface".)

GMBitmapList

This container simplifies management of your GMBitmaps. You can store a series of GMBitmaps in a GMBitmapList and simply refer to each by an index value, or you can use the GetRandom function (provided) to grab a bitmap from the list at random. You can also use a GMBitmapList to automatically handle all the frames of an animated image.

GMSprite

A sprite is an image that moves around the screen. A sprite may have one image for its shape, or multiple frames so it animates as it moves. The bitmap belonging to a sprite is assigned a transparent color, so the background shows through as it moves. GMSprites may also be assigned behaviors (see the GMBehavior object) that describe how the sprite will move on the screen.

GMSpriteList

You can use this container to hold all your active sprites. At every time interval that you want to change the display, you can simply cycle through your GMSpriteList and tell every GMSprite stored there to move itself. Or you can send the Move command to the GMSpriteList itself, and it will automatically move every GMSprite in the list.

GMBehavior

This is a virtual object that can be assigned to each of your GMSprites. GMBehavior defines what any behavior object must include in its definition. You can define your own behaviors by inheriting from the GMBehavior object. An example called BehaviorBounce is provided as part of the standard Graphics Magician library. Assign a "new BehaviorBounce" to your sprites to see it in action.

GMCollision, GMCollisionReport

The values of these objects are set by the GMSprite's Collided function. After testing for collisions, details of collisions that have occurred are stored in a GMCollision object. A GMCollisionReport contains a list of (possible) multiple collisions between a GMSprite and all the sprites in a GMSpriteList.

GMSound

The GMSound object lets you more efficiently manage WAV files that are played in your program. The PlayWave function provided with the GMMachine uses only one GMSound. Creating your own GMSound objects lets you keep several sounds in memory so they are all immediately accessible. You can also open multiple copies of an individual sound so it can be played concurrently with itself.