1 #ifndef __GAMEOBJECT_HPP__
2 #define __GAMEOBJECT_HPP__
9 * Base class for all game objects. This contains functions for:
10 * -querying the actual type of the object
11 * -a flag that indicates if the object wants to be removed. Objects with this
12 * flag will be removed at the end of each frame. This is alot safer than
13 * having some uncontrollable "delete this" in the code.
14 * -an action function that is called once per frame and allows the object to
17 * Most GameObjects will also implement the DrawableObject interface so that
18 * they can actually be drawn on screen.
20 class GameObject // TODO rename this once the game has been converted
24 virtual ~GameObject();
26 /** returns the name of the objecttype, this is mainly usefull for the editor.
27 * For the coding part you should use C++ RTTI (ie. typeid and dynamic_cast)
30 virtual std::string type() const = 0;
31 /** This function is called once per frame and allows the object to update
32 * it's state. The elapsed_time is the time since the last frame and should be
33 * the base for all timed things.
35 virtual void action(float elapsed_time) = 0;
37 /** returns true if the object is not scheduled to be removed yet */
39 { return !wants_to_die; }
40 /** schedules this object to be removed at the end of the frame */
42 { wants_to_die = true; }
45 /** this flag indicates if the object should be removed at the end of the