Programming Cinematic Sequences

Started by
0 comments, last by bzroom 13 years, 12 months ago
I would like to know how to program a game engine which supports Cinematic Sequences. I am using the term 'Cinematic Sequences' to define scripted events which occur during the execution of a time-line. Events can: - create and delete game objects - change a sprite or models animation sequence - spawn a particle effect - display some dialog - over time move a game object from one position/rotation to another - fade out the current music and replace with new music - control complex sequences required to animate a level/gameobject of some sort - some scripts are used to control a sequence of events i.e. boss battles - some disable the player i.e. a cut-scene - some scripts create complex game-play features: e.g. particle effects to appear in a timed manner during firing a weapon I would really appreciate it if someone could direct me to a book/good source of information or even supply some code samples relating to the implementation of such a system in a game engine.
Advertisement
One approach is to simply use an array of callbacks. Where call back is just basically a function object. All of those different elements you mentioned would inherit from the callback base. You'd create an array of these callbacks to compose the cut scene, and then just iterate the callbacks to run it. You may want to add a "ready to call" function to the callbacks to hault execution for things like timers or waiting for a particular state such as something destroyed.

struct ICallback{  virtual ~ICallback( ) { }  virtual bool Ready( float dt ) { return true; }  virtual void Execute( ) { }};struct Timer : public ICallback{  float mTimeLeft    Timer( float delay ) : mTimeLeft( delay ) { }  virtual bool Ready( float dt ) { mTimeLeft -= dt; return mTimeLeft <= 0; }};struct Effect : public ICallback{  std::string mEffectPath;  Effect( const std::string& effect ) : mEffectPath( effect ) { }  virtual void Execute( ) { Game::Engine().SpawnEffect( mEffectPath ); }};struct BasicCutscene{  std::vector<ICallback*> mEvents;  int mIndex;  BasicCutScene( )   : mIndex( 0 )  {    mEvents.push_back( new Timer( 2.0f ) );    mEvents.push_back( new Effect( "shizam.pfx" ) );  }  ~BasicCutScene( ) { /*do some shiz here*/  void Step( float dt )  {	while( mIndex < mEvents.size( ) && mEvents[index].Ready( dt ) )        {           mEvents[index].Execute( );           ++index;        }          }};

This topic is closed to new replies.

Advertisement