coeng
diff src/gobj.h @ 6:2f872a179914
first component test:
- prs, xform, physics components with dependencies
- topological sort of components to update them in the correct order
- debug visualization component
todo: remove draw() from components, doesn't make sense
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 14 Feb 2015 07:27:12 +0200 |
parents | 0e5da17d589c |
children |
line diff
1.1 --- a/src/gobj.h Sat Feb 14 01:35:42 2015 +0200 1.2 +++ b/src/gobj.h Sat Feb 14 07:27:12 2015 +0200 1.3 @@ -1,29 +1,32 @@ 1.4 -#ifndef GAMEOBJECT_H_ 1.5 -#define GAMEOBJECT_H_ 1.6 +#ifndef GOBJECT_H_ 1.7 +#define GOBJECT_H_ 1.8 1.9 #include <vector> 1.10 #include <map> 1.11 #include <string> 1.12 #include "comp.h" 1.13 1.14 -class GameObject { 1.15 +class GObject { 1.16 private: 1.17 std::vector<Component*> comp; 1.18 std::map<std::string, Component*> comp_by_name; 1.19 1.20 bool sorted; 1.21 1.22 + void sort_components(); 1.23 + 1.24 public: 1.25 - GameObject(); 1.26 - ~GameObject(); 1.27 + GObject(); 1.28 + ~GObject(); 1.29 1.30 - bool add_component(Component *c); // takes ownership 1.31 - bool remove_component(Component *c); 1.32 + bool add_component(Component *c); // takes ownership 1.33 + bool remove_component(Component *c); // whoever calls this, now has ownership 1.34 bool delete_component(Component *c); 1.35 1.36 Component *get_component(const char *name) const; 1.37 1.38 - void update(); 1.39 + void update(float dt = 0.0f); 1.40 + void draw() const; 1.41 }; 1.42 1.43 -#endif // GAMEOBJECT_H_ 1.44 +#endif // GOBJECT_H_