BaseEngineInterface - JayhawkZombie/EECS581Project GitHub Wiki

BaseEngineInterface

This class is the highest-level that the engine can directly communicate with.

It comes with a set of methods, some of which must be overridden in your derived class.

Pure Virtual Methods
virtual void TickUpdate(const double &TickDelta) = 0;

  • This function is called every frame that your object is active (or within view of the screen, if being rendered).
  • Use this function to do any time-based logic you need to do, such as advancing animations, moving your objects, timing, etc.
  • Param(s): const double &delta - const reference to double representing the number of milliseconds passed since the last frame update occurred

virtual void Render(std::shared_ptr<sf::RenderTarget> Target) = 0;

  • This function is called every frame that you are to be rendered.
  • You may call Target->draw(...) and pass in any SFML primitive (or properly derived object from sf::Drawable)
  • It is important to remember that the last render wins so anything drawn after your object could obscure the view of you
  • Param(s): std::shared_ptr<sf::RenderTarget> - a shared_ptr to the render target onto which you may draw your object (see sf::RenderTarget for documentation on RenderTarget)

virtual void OnShutDown() = 0;

  • This function is called when the engine is shutting down if your object is still alive at that time
  • You may use this function to do any cleanup necessary, like closing file handles, saving your state, etc
  • Param(s): None

virtual void SerializeOut(std::ofstream &out) = 0;

  • This function is called when your object is receiving a request to serialize itself to a file. This can occur at any time, so do not assume that this means the engine is shutting down.
  • You can use this to save any information your class needs in order to be able to reconstruct itself. Your object must be able to reconstruct its old state using only the information you saved to this file.
  • Param(s): std::ofstream &out - a reference to a standard output file stream

virtual void SerializeIn(std::ifstream &in) = 0;

  • This function is called when your object is receiving a request to reconstruct itself from a serialized file. This can occur at any time.
  • You can use the information used to reconstruct your object's state as it was when the data was serialized
  • Param(s): std::ifstream &in - a reference to a standard input file stream

Optional overrides
You can choose to override these if you wish, but it is not necessary.

virtual void EventUpdate(sf::Event event);

  • This function is called to instruct your object to directly handle an input event from the user. See sf::Event for documentation on sf::Event

virtual void HandleInputEvent(const UserEvent &evnt);

  • This function is called to instruct your object to handle an input event, but events will be filtered and translated into a version mostly abstracted away from the SFML implementation