aboutsummaryrefslogtreecommitdiff
path: root/src/libjin/Game
diff options
context:
space:
mode:
Diffstat (limited to 'src/libjin/Game')
-rw-r--r--src/libjin/Game/je_application.cpp81
-rw-r--r--src/libjin/Game/je_application.h88
-rw-r--r--src/libjin/Game/je_entity.cpp0
-rw-r--r--src/libjin/Game/je_entity.h27
-rw-r--r--src/libjin/Game/je_gameobject.cpp11
-rw-r--r--src/libjin/Game/je_gameobject.h83
-rw-r--r--src/libjin/Game/je_scene.cpp0
-rw-r--r--src/libjin/Game/je_scene.h73
8 files changed, 0 insertions, 363 deletions
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 <iostream>
-
-#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<Application>
- {
- 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
--- a/src/libjin/Game/je_entity.cpp
+++ /dev/null
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 <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
-
- Math::Transform mTransform;
-
- };
-
- ///
- /// 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.cpp b/src/libjin/Game/je_scene.cpp
deleted file mode 100644
index e69de29..0000000
--- a/src/libjin/Game/je_scene.cpp
+++ /dev/null
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 <map>
-#include <list>
-
-#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<uint32, EntityList> layers;
- // all entities grouped by tag
- std::map<uint32, EntityList> tags;
-
- };
-
- } // namespace Game
-} // namespace JinEngine
-
-#endif // jin_game
-
-#endif \ No newline at end of file