From 7cce806948349c77a9863e6c5328d20f463f8b6c Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 28 Jul 2018 23:28:48 +0800 Subject: *update --- src/libjin/Tools/Component/Component.h | 30 +++++++++++++++++++++++++ src/libjin/Tools/Component/GameObject.h | 40 +++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 src/libjin/Tools/Component/Component.h create mode 100644 src/libjin/Tools/Component/GameObject.h (limited to 'src/libjin/Tools/Component') diff --git a/src/libjin/Tools/Component/Component.h b/src/libjin/Tools/Component/Component.h new file mode 100644 index 0000000..12c347a --- /dev/null +++ b/src/libjin/Tools/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 tools +{ + + 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/Tools/Component/GameObject.h b/src/libjin/Tools/Component/GameObject.h new file mode 100644 index 0000000..aac9e6b --- /dev/null +++ b/src/libjin/Tools/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 +#include "Component.h" + +namespace jin +{ +namespace tools +{ + + 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 components; + }; + +} // tools +} // jin + +#endif // JIN_MODULES_TOOLS && JIN_TOOLS_COMPONENT +#endif // __JIN_TOOLS_GAMEOBJECT_H \ No newline at end of file -- cgit v1.1-26-g67d0