[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ] [ Search: ] Explosion Class

This is a very simple class that keeps track of an explosion. Once the explosion particle system has died out the instance of this class will be removed as well.

class Explosion
  csRef<iMeshWrapper> mesh;
  int timeleft;

  Explosion (iMeshWrapper* mesh, int timeleft);

  bool Handle (csTicks elapsed_ticks);

  iMeshWrapper* GetMesh () const { return mesh; }

The main function here is the Handle() function. This one takes the elapsed ticks (i.e. milliseconds) since last frame which it will use to decide when to delete the explosion mesh.

Explosion::Explosion (iMeshWrapper* mesh, int timeleft)
  Explosion::mesh = mesh;
  Explosion::timeleft = timeleft;

bool Explosion::Handle (csTicks elapsed_ticks)
  timeleft -= elapsed_ticks;
  if (timeleft <= 0)
    return false;
  return true;

The implementation is very simple. The Explosion class is instantiated with a certain lifetime (see later). Every frame Handle() will be called which will subtract the elapsed ticks from the lifetime. When the lifetime becomes smaller or equal then 0 then the explosion should be removed.

This document was generated using texi2html 1.76.