Game Development Reference
In-Depth Information
class VisualizerObject
{
friend class VisualizerManager;
public:
VisualizerObject(VO_CATEGORY category)
{
// Register this object on construction with
// the VisualiserManager so that it can loop through
// all its registered objects each frame and call
// draw as appropriate!
VisualizerManager::registerObject( this, category );
}
virtual ~VisualizerObject() {}
// Virtual method which will need to be defined by inherited
// classes.
virtual void draw() = 0;
protected:
bool m_active; // Set to true when the object is actively
// being processed by the game.
};
Listing 11.4. Sample VisualizerObject base class.
Implementation. Visualizations of sound data should keep to a consistent color
scheme. The programmer can use, for example, red for inactive objects, green for
active objects, and blue for active objects that are unable to perform their actions.
For example, a sound that has tried to play but failed would show up as blue in
this color scheme.
Active sounds in the game world are rendered by the game as a small piece of
colored geometry to show their position. They are colored differently depending
on whether they are being played, are unable to play, or are inaudible. The colors
they use to represent these states must keep within the previously mentioned color
scheme. A circle surrounding them can be optionally rendered to show their audible
distance.
// Example base class to be inherited by all game objects
// which play a sound. Each one is given its own id.
class SoundObject : public VisualizerObject
{
public:
SoundObject() : VisualizerObject( VO_SOUND ),
m_sound( null ), m_event( null ),
m_id( m_shared_id_counter++ ) {}
virtual ~SoundObject() {}
Search WWH ::




Custom Search