diff options
Diffstat (limited to 'src/libjin/Game')
-rw-r--r-- | src/libjin/Game/je_application.cpp (renamed from src/libjin/Game/je_game.cpp) | 14 | ||||
-rw-r--r-- | src/libjin/Game/je_application.h (renamed from src/libjin/Game/je_game.h) | 16 | ||||
-rw-r--r-- | src/libjin/Game/je_entity.cpp | 11 | ||||
-rw-r--r-- | src/libjin/Game/je_entity.h | 64 | ||||
-rw-r--r-- | src/libjin/Game/je_gameobject.cpp | 11 | ||||
-rw-r--r-- | src/libjin/Game/je_gameobject.h | 86 | ||||
-rw-r--r-- | src/libjin/Game/je_scene.h | 12 |
7 files changed, 126 insertions, 88 deletions
diff --git a/src/libjin/Game/je_game.cpp b/src/libjin/Game/je_application.cpp index 6eb1d3f..a5a8812 100644 --- a/src/libjin/Game/je_game.cpp +++ b/src/libjin/Game/je_application.cpp @@ -8,11 +8,11 @@ #include "../graphics/je_window.h" #include "../math/je_math.h" -#include "je_game.h" +#include "je_application.h" namespace JinEngine { - namespace Core + namespace Game { using namespace JinEngine::Graphics; @@ -20,10 +20,10 @@ namespace JinEngine using namespace JinEngine::Time; using namespace JinEngine::Math; - Game::Game() :_running(true) {}; + Application::Application() :_running(true) {}; /* default game loop */ - void Game::run() + void Application::run() { if (_onLoad != nullptr) _onLoad(); @@ -57,11 +57,11 @@ namespace JinEngine quitloop:; } - bool Game::initSystem(const SettingBase* setting) + bool Application::initSystem(const SettingBase* setting) { if (setting == nullptr) return false; - Game::Setting* s = (Game::Setting*) setting; + Application::Setting* s = (Application::Setting*) setting; _onEvent = s->eventHandler; _onUpdate = s->updater; _onDraw = s->drawer; @@ -69,7 +69,7 @@ namespace JinEngine return true; } - void Game::quitSystem() + void Application::quitSystem() { } diff --git a/src/libjin/Game/je_game.h b/src/libjin/Game/je_application.h index 78c3385..094de6a 100644 --- a/src/libjin/Game/je_game.h +++ b/src/libjin/Game/je_application.h @@ -1,5 +1,5 @@ -#ifndef __JE_CORE_GAME_H -#define __JE_CORE_GAME_H +#ifndef __JE_CORE_GAME_H__ +#define __JE_CORE_GAME_H__ #include "../core/je_configuration.h" #if defined(jin_game) @@ -12,13 +12,13 @@ namespace JinEngine { - namespace Core + namespace Game { /// /// Game class. /// - class Game : public Subsystem<Game> + class Application : public Subsystem<Application> { public: @@ -63,10 +63,10 @@ namespace JinEngine private: - Game(); - ~Game() {}; + Application(); + ~Application() {}; - singleton(Game); + singleton(Application); onEvent _onEvent; onUpdate _onUpdate; @@ -85,4 +85,4 @@ namespace JinEngine #endif // jin_game -#endif // __JE_CORE_GAME_H
\ No newline at end of file +#endif // __JE_CORE_GAME_H__
\ No newline at end of file diff --git a/src/libjin/Game/je_entity.cpp b/src/libjin/Game/je_entity.cpp index 1396518..e69de29 100644 --- a/src/libjin/Game/je_entity.cpp +++ b/src/libjin/Game/je_entity.cpp @@ -1,11 +0,0 @@ -#include "je_entity.h" - -namespace JinEngine -{ - namespace Game - { - - - - } // namespace Game -} // namespace JinEngine
\ No newline at end of file diff --git a/src/libjin/Game/je_entity.h b/src/libjin/Game/je_entity.h index 4a252da..39822b6 100644 --- a/src/libjin/Game/je_entity.h +++ b/src/libjin/Game/je_entity.h @@ -1,15 +1,7 @@ -#ifndef __JE_GAME_OBJECT_H -#define __JE_GAME_OBJECT_H +#ifndef __JE_ENTITY_H__ +#define __JE_ENTITY_H__ -#include "../core/je_configuration.h" -#if defined(jin_game) - -#include <list> -#include <map> -#include <set> - -#include "../common/je_object.h" -#include "../common/je_types.h" +#include "je_gameobject.h" namespace JinEngine { @@ -17,59 +9,19 @@ namespace JinEngine { /// - /// Game object base class. + /// /// - class Entity : public Object + class Entity : public GameObject { public: + Entity(); - /// - /// - /// - virtual ~Entity(); - - /// - /// - /// - void lifecycle(); - - /// - /// - /// - void setVisible(bool isVisible); + private: - /// - /// - /// - void setActive(bool isActive); - - protected: - virtual void onAlive(); - virtual void onUpdate(float dt); - virtual void onDraw(); - virtual void onDie(); - - uint32 layer; // layer where entity belongs - uint32 index; // render index in layer - uint64 tag; // tag of entity, 64 now - bool mIsVisible; // if the entity is visible or not - bool mIsActive; // if the entity is joined into the logic }; - /// - /// Entity list. For quickly adding and removing entities. - /// - typedef std::list<Entity*> EntityList; - - /// - /// Entity set. For searching and keeps entities unique and sorted. - /// - typedef std::set<Entity*> EntitySet; - } // namespace Game -} // namespace JinEngine - -#endif // jin_game +} // namespace JinEngine #endif
\ No newline at end of file diff --git a/src/libjin/Game/je_gameobject.cpp b/src/libjin/Game/je_gameobject.cpp new file mode 100644 index 0000000..1396518 --- /dev/null +++ b/src/libjin/Game/je_gameobject.cpp @@ -0,0 +1,11 @@ +#include "je_entity.h" + +namespace JinEngine +{ + namespace Game + { + + + + } // namespace Game +} // namespace JinEngine
\ No newline at end of file diff --git a/src/libjin/Game/je_gameobject.h b/src/libjin/Game/je_gameobject.h new file mode 100644 index 0000000..fefc6df --- /dev/null +++ b/src/libjin/Game/je_gameobject.h @@ -0,0 +1,86 @@ +#ifndef __JE_GAME_OBJECT_H__ +#define __JE_GAME_OBJECT_H__ + +#include "../core/je_configuration.h" +#if defined(jin_game) + +#include <list> +#include <map> +#include <set> + +#include "../common/je_object.h" +#include "../common/je_types.h" +#include "../graphics/je_sprite.h" + +namespace JinEngine +{ + namespace Game + { + + /// + /// Game object base class. + /// + class GameObject : public Object + { + public: + + /// + /// + /// + virtual ~GameObject(); + + /// + /// + /// + void lifecycle(); + + /// + /// + /// + void setVisible(bool isVisible); + + /// + /// + /// + void setActive(bool isActive); + + /// + /// + /// + void setOrder(uint32 order); + + protected: + virtual void onAlive(); + virtual void onUpdate(float dt); + virtual void onDraw(); + virtual void onDestroy(); + + uint32 mLayer; // layer where entity belongs + uint32 mOrder; // render index in layer + uint32 mTag; // tag of entity, support 32 tags now + bool mIsVisible; // if the entity is visible or not + bool mIsActive; // if the entity is joined into the logic + + /// + /// Position of entity. + /// + Math::Vector2<float> mPosition; + + }; + + /// + /// Entity list. For quickly adding and removing entities. + /// + typedef std::list<GameObject*> EntityList; + + /// + /// Entity set. For searching and keeps entities unique and sorted. + /// + typedef std::set<GameObject*> EntitySet; + + } // namespace Game +} // namespace JinEngine + +#endif // jin_game + +#endif
\ No newline at end of file diff --git a/src/libjin/Game/je_scene.h b/src/libjin/Game/je_scene.h index f510a1f..811d1a8 100644 --- a/src/libjin/Game/je_scene.h +++ b/src/libjin/Game/je_scene.h @@ -1,5 +1,5 @@ -#ifndef __JE_GAME_SCENE_H -#define __JE_GAME_SCENE_H +#ifndef __JE_GAME_SCENE_H__ +#define __JE_GAME_SCENE_H__ #include "../core/je_configuration.h" #if defined(jin_game) @@ -28,7 +28,7 @@ namespace JinEngine /// /// /// - EntityList& getEntitiesByTag(uint64 tag); + EntityList& getEntitiesByTag(uint32 tag); /// /// @@ -38,7 +38,7 @@ namespace JinEngine /// /// /// - void setEntitiesActiveByTag(uint64 tag); + void setEntitiesActiveByTag(uint32 tag); /// /// @@ -53,7 +53,7 @@ namespace JinEngine /// /// /// - void removeEntitiesByTag(uint64 tag); + void removeEntitiesByTag(uint32 tag); protected: // all entities @@ -61,7 +61,7 @@ namespace JinEngine // all entities grouped by layer, render order std::map<uint32, EntityList> layers; // all entities grouped by tag - std::map<uint64, EntityList> tags; + std::map<uint32, EntityList> tags; }; |