From 8cb74178c2b8e5883a1181af687fa8cfc0c6e5da Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 18 Nov 2018 23:44:40 +0800 Subject: =?UTF-8?q?*=E4=BF=AE=E6=94=B9=E7=9B=AE=E5=BD=95=E4=B8=BA=E5=B0=8F?= =?UTF-8?q?=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libjin/Game/je_application.cpp | 81 ----------------------------------- src/libjin/Game/je_application.h | 88 -------------------------------------- src/libjin/Game/je_entity.cpp | 0 src/libjin/Game/je_entity.h | 27 ------------ src/libjin/Game/je_gameobject.cpp | 11 ----- src/libjin/Game/je_gameobject.h | 83 ----------------------------------- src/libjin/Game/je_scene.cpp | 0 src/libjin/Game/je_scene.h | 73 ------------------------------- 8 files changed, 363 deletions(-) delete mode 100644 src/libjin/Game/je_application.cpp delete mode 100644 src/libjin/Game/je_application.h delete mode 100644 src/libjin/Game/je_entity.cpp delete mode 100644 src/libjin/Game/je_entity.h delete mode 100644 src/libjin/Game/je_gameobject.cpp delete mode 100644 src/libjin/Game/je_gameobject.h delete mode 100644 src/libjin/Game/je_scene.cpp delete mode 100644 src/libjin/Game/je_scene.h (limited to 'src/libjin/Game') diff --git a/src/libjin/Game/je_application.cpp b/src/libjin/Game/je_application.cpp deleted file mode 100644 index 723a809..0000000 --- a/src/libjin/Game/je_application.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include "../core/je_configuration.h" -#if defined(jin_game) - -#include - -#include "../time/je_timer.h" -#include "../input/je_event.h" -#include "../graphics/je_window.h" -#include "../graphics/je_gl.h" -#include "../math/je_math.h" - -#include "je_application.h" - -using namespace JinEngine::Graphics; -using namespace JinEngine::Input; -using namespace JinEngine::Time; -using namespace JinEngine::Math; - -namespace JinEngine -{ - namespace Game - { - - Application::Application() :_running(true) {}; - - /* default game loop */ - void Application::run() - { - if (_onLoad != nullptr) - _onLoad(); - Window* wnd = Window::get(); - const int FPS = wnd ? wnd->getFPS() : 60; - const int MS_PER_UPDATE = 1000.0f / FPS; - _running = true; - Event e; - int current = getMilliSecond(); - int previous = current; - int dt = 0; - while (_running) - { - while (JinEngine::Input::pollEvent(&e)) - { - if (_onEvent != nullptr) - _onEvent(&e); - if (!_running) - goto quitloop; - } - previous = current; - current = getMilliSecond(); - dt = current - previous; - if (_onUpdate != nullptr) - _onUpdate(dt); - glClear(GL_COLOR_BUFFER_BIT); - if (_onDraw != nullptr) - _onDraw(); - wnd->swapBuffers(); - sleep(1); - } - quitloop:; - } - - bool Application::initSystem(const SettingBase* setting) - { - if (setting == nullptr) - return false; - Application::Setting* s = (Application::Setting*) setting; - _onEvent = s->eventHandler; - _onUpdate = s->updater; - _onDraw = s->drawer; - _onLoad = s->loader; - return true; - } - - void Application::quitSystem() - { - } - - } // namespace Core -} // namespace JinEngine - -#endif // jin_game \ No newline at end of file diff --git a/src/libjin/Game/je_application.h b/src/libjin/Game/je_application.h deleted file mode 100644 index 094de6a..0000000 --- a/src/libjin/Game/je_application.h +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef __JE_CORE_GAME_H__ -#define __JE_CORE_GAME_H__ - -#include "../core/je_configuration.h" -#if defined(jin_game) - -#include "../common/je_subsystem.hpp" -#include "../utils/je_macros.h" -#include "../input/je_Event.h" - -#include "SDL2/SDL.h" - -namespace JinEngine -{ - namespace Game - { - - /// - /// Game class. - /// - class Application : public Subsystem - { - public: - - typedef void(*onLoad)(); - typedef void(*onEvent)(JinEngine::Input::Event* e); - typedef void(*onUpdate)(int dt); - typedef void(*onDraw)(); - - /// - /// Game setting. - /// - struct Setting : SettingBase - { - onEvent eventHandler; - onUpdate updater; - onDraw drawer; - onLoad loader; - }; - - /// - /// Main game loop. - /// - void run(); - - /// - /// Stop game. - /// - inline void stop() - { - _running = false; - }; - - /// - /// Return if game is running. - /// - /// @return True if game is running, otherwise return false. - /// - inline bool running() - { - return _running; - }; - - private: - - Application(); - ~Application() {}; - - singleton(Application); - - onEvent _onEvent; - onUpdate _onUpdate; - onDraw _onDraw; - onLoad _onLoad; - - bool _running; - - bool initSystem(const SettingBase* setting); - void quitSystem(); - - }; - - } // namespace Core -} // namespace JinEngine - -#endif // jin_game - -#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 deleted file mode 100644 index e69de29..0000000 diff --git a/src/libjin/Game/je_entity.h b/src/libjin/Game/je_entity.h deleted file mode 100644 index 80c6ff3..0000000 --- a/src/libjin/Game/je_entity.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef __JE_ENTITY_H__ -#define __JE_ENTITY_H__ - -#include "je_gameobject.h" - -namespace JinEngine -{ - namespace Game - { -/* - /// - /// - /// - class Entity : public GameObject - { - public: - Entity(); - - private: - - - }; -*/ - } // namespace 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 deleted file mode 100644 index 1396518..0000000 --- a/src/libjin/Game/je_gameobject.cpp +++ /dev/null @@ -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_gameobject.h b/src/libjin/Game/je_gameobject.h deleted file mode 100644 index 7c6ec2b..0000000 --- a/src/libjin/Game/je_gameobject.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef __JE_GAME_OBJECT_H__ -#define __JE_GAME_OBJECT_H__ - -#include "../core/je_configuration.h" -#if defined(jin_game) - -#include -#include -#include - -#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 - - Math::Transform mTransform; - - }; - - /// - /// Entity list. For quickly adding and removing entities. - /// - typedef std::list EntityList; - - /// - /// Entity set. For searching and keeps entities unique and sorted. - /// - typedef std::set EntitySet; - */ - } // namespace Game -} // namespace JinEngine - -#endif // jin_game - -#endif \ No newline at end of file diff --git a/src/libjin/Game/je_scene.cpp b/src/libjin/Game/je_scene.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/src/libjin/Game/je_scene.h b/src/libjin/Game/je_scene.h deleted file mode 100644 index 811d1a8..0000000 --- a/src/libjin/Game/je_scene.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef __JE_GAME_SCENE_H__ -#define __JE_GAME_SCENE_H__ - -#include "../core/je_configuration.h" -#if defined(jin_game) - -#include -#include - -#include "je_entity.h" - -namespace JinEngine -{ - namespace Game - { - - /// - /// Handle all entities. - /// - class Scene - { - public: - /// - /// - /// - void addEntity(Entity* entity); - - /// - /// - /// - EntityList& getEntitiesByTag(uint32 tag); - - /// - /// - /// - EntityList& getEntitiesByLayer(uint32 layer); - - /// - /// - /// - void setEntitiesActiveByTag(uint32 tag); - - /// - /// - /// - void setEntitiesActiveByLayer(uint32 layer); - - /// - /// - /// - void removeEntitiesByLayer(uint32 layer); - - /// - /// - /// - void removeEntitiesByTag(uint32 tag); - - protected: - // all entities - EntitySet entities; - // all entities grouped by layer, render order - std::map layers; - // all entities grouped by tag - std::map tags; - - }; - - } // namespace Game -} // namespace JinEngine - -#endif // jin_game - -#endif \ No newline at end of file -- cgit v1.1-26-g67d0