I'm don't knwo how your game engine is layed out, but a kernel approch seems popular. You have a game engine that houses services for your game objects to use.
When you create the object, you register it with the engine. When it's registered, it tells the engine what services it requiers. It hooks-up each interface it implements to the corresponding service the kernel provides.
An example service, is a virtual-time-phase-locked timer that invokes a virtual Tick(Time now, Kernel*) method on your object when it is time to update the object for the next simulation round. In this update routine, you can invoke whatever kernel services are required by your object - call into the physic engine to do work to update your velocity vectors etc... call into the graphics engine to manipulate your textures, meshes, etc... call into the audio engine to set up a sfx.
After calling Tick on all the objects, then you update the actual audio (mix in new sounds, stop expired soudns) & graphics (render the next frame).
Another example service, could be a collision detector. You tell the CD your object cares about collisions, and if it detects a collision, it calls your object - say through the ICollidiable::HitDetected(Kernel*, ICollidiable* object_hit) interface - to inform the object of the event. You could have a couple of different collide events this way, maybe one for CD with an immobible objects (walls), a different one for two moving objects hitting each other, and maybe a special one for weapon hits - ICollidiable::ImHit(Kernel*, IWeapon*).
(You would also want to use the CD for rendering - CD the viewing frustrum with the geometry, and you have the objects that need to be drawn).
quote:Original post by VizOne
In fact, MI is (almost) never neccessary. Guess why Java, .NET etc. got rid of it?
They didn't get rid of it, they just restricted it to abstract classes/interfaces only; more like rebranding than removal.
[edited by - Magmai Kai Holmlor on October 22, 2003 12:51:04 PM]
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara