diff options
author | chai <chaifix@163.com> | 2018-08-06 16:22:00 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-08-06 16:22:00 +0800 |
commit | 89e7a9ecfad9a54633eb3ebbab1d1f13ad78826f (patch) | |
tree | 1ba8a806af1b8e7750d6b637c296f08e13cf268e /src/libjin/Utils/Component | |
parent | ea9769944a2db3abe15f537dab67e16fdfc20bef (diff) |
*update
Diffstat (limited to 'src/libjin/Utils/Component')
-rw-r--r-- | src/libjin/Utils/Component/Component.h | 30 | ||||
-rw-r--r-- | src/libjin/Utils/Component/GameObject.h | 40 |
2 files changed, 70 insertions, 0 deletions
diff --git a/src/libjin/Utils/Component/Component.h b/src/libjin/Utils/Component/Component.h new file mode 100644 index 0000000..f63fb59 --- /dev/null +++ b/src/libjin/Utils/Component/Component.h @@ -0,0 +1,30 @@ +#ifndef __JIN_TOOLS_COMPONENT_H +#define __JIN_TOOLS_COMPONENT_H +#include "../../modules.h" +#if JIN_MODULES_TOOLS && JIN_TOOLS_COMPONENT + +namespace jin +{ +namespace utils +{ + + class GameObject; + + class Component + { + public: + Component(GameObject* obj) + : gameObject(obj) + {} + + virtual void update(float dt) = 0; + + private: + GameObject* gameObject; + }; + +} // tools +} // jin + +#endif // JIN_MODULES_TOOLS && JIN_TOOLS_COMPONENT +#endif // __JIN_TOOLS_COMPONENT_H
\ No newline at end of file diff --git a/src/libjin/Utils/Component/GameObject.h b/src/libjin/Utils/Component/GameObject.h new file mode 100644 index 0000000..e4f3aa5 --- /dev/null +++ b/src/libjin/Utils/Component/GameObject.h @@ -0,0 +1,40 @@ +#ifndef __JIN_TOOLS_GAMEOBJECT_H +#define __JIN_TOOLS_GAMEOBJECT_H +#include "../../modules.h" +#if JIN_MODULES_TOOLS && JIN_TOOLS_COMPONENT + +#include <vector> +#include "Component.h" + +namespace jin +{ +namespace utils +{ + + class GameObject + { + public: + + GameObject() + : components() + { + } + + virtual void update(float dt) + { + for each (Component* component in components) + component->update(dt); + } + + virtual void draw() = 0; + + protected: + + std::vector<Component*> components; + }; + +} // tools +} // jin + +#endif // JIN_MODULES_TOOLS && JIN_TOOLS_COMPONENT +#endif // __JIN_TOOLS_GAMEOBJECT_H
\ No newline at end of file |