diff options
Diffstat (limited to 'src/libjin/Core')
-rw-r--r-- | src/libjin/Core/Core.h | 6 | ||||
-rw-r--r-- | src/libjin/Core/Game.cpp | 72 | ||||
-rw-r--r-- | src/libjin/Core/Game.h | 58 | ||||
-rw-r--r-- | src/libjin/Core/README.md | 1 | ||||
-rw-r--r-- | src/libjin/Core/je_configuration.h | 53 | ||||
-rw-r--r-- | src/libjin/Core/je_version.h | 52 |
6 files changed, 106 insertions, 136 deletions
diff --git a/src/libjin/Core/Core.h b/src/libjin/Core/Core.h deleted file mode 100644 index dd902b4..0000000 --- a/src/libjin/Core/Core.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef __JIN_CORE_H -#define __JIN_CORE_H - -#include "game.h" - -#endif
\ No newline at end of file diff --git a/src/libjin/Core/Game.cpp b/src/libjin/Core/Game.cpp deleted file mode 100644 index b480b12..0000000 --- a/src/libjin/Core/Game.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include "game.h" -#include "../Time/Timer.h" -#include "../input/Event.h" -#include "../Graphics/Window.h" -#include "../Math/Math.h" -#include <iostream> - -namespace jin -{ -namespace core -{ - - using namespace jin::graphics; - using namespace jin::input; - using namespace jin::time; - using namespace jin::math; - - Game::Game() :_running(true) {}; - - void Game::run() - { - SAFECALL(_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 previous = getMilliSecond(); - int dt = MS_PER_UPDATE; - while (_running) - { - while (jin::input::pollEvent(&e)) - { - SAFECALL(_onEvent, &e); - if (!_running) goto quitloop; - } - SAFECALL(_onUpdate, dt); - SAFECALL(_onDraw); - wnd->swapBuffers(); - const int current = getMilliSecond(); - dt = current - previous; - const int wait = MS_PER_UPDATE - (current - previous); - previous += MS_PER_UPDATE; - if (wait > 0) - { - sleep(wait); - dt = MS_PER_UPDATE; - } - else - previous = current; - } - quitloop:; - } - - bool Game::initSystem(const SettingBase* setting) - { - if (setting == nullptr) - return false; - Game::Setting* s = (Game::Setting*) setting; - _onEvent = s->eventHandler; - _onUpdate = s->updater; - _onDraw = s->drawer; - _onLoad = s->loader; - return true; - } - - void Game::quitSystem() - { - } - -} // core -} // jin
\ No newline at end of file diff --git a/src/libjin/Core/Game.h b/src/libjin/Core/Game.h deleted file mode 100644 index 31f32d8..0000000 --- a/src/libjin/Core/Game.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef __JIN_CORE_GAME_H -#define __JIN_CORE_GAME_H - -#include "SDL2/SDL.h" - -#include "../Common/Subsystem.hpp" -#include "../utils/macros.h" -#include "../Input/Event.h" - -namespace jin -{ -namespace core -{ - - class Game : public Subsystem<Game> - { - public: - - typedef void(*onLoad)(); - typedef void(*onEvent)(jin::input::Event* e); - typedef void(*onUpdate)(int dt); - typedef void(*onDraw)(); - - struct Setting : SettingBase - { - onEvent eventHandler; - onUpdate updater; - onDraw drawer; - onLoad loader; - }; - - void run(); - inline void stop() { _running = false; }; - inline bool running() { return _running; }; - - private: - - Game(); - ~Game() {}; - - SINGLETON(Game); - - onEvent _onEvent; - onUpdate _onUpdate; - onDraw _onDraw; - onLoad _onLoad; - - bool _running; - - bool initSystem(const SettingBase* setting); - void quitSystem(); - - }; - -} // core -} // jin - -#endif // __JIN_CORE_GAME_H
\ No newline at end of file diff --git a/src/libjin/Core/README.md b/src/libjin/Core/README.md new file mode 100644 index 0000000..b393007 --- /dev/null +++ b/src/libjin/Core/README.md @@ -0,0 +1 @@ +ļµļƱṩһЩ汾Ϣ
\ No newline at end of file diff --git a/src/libjin/Core/je_configuration.h b/src/libjin/Core/je_configuration.h new file mode 100644 index 0000000..34c3a74 --- /dev/null +++ b/src/libjin/Core/je_configuration.h @@ -0,0 +1,53 @@ +#ifndef __JE_COMMON_MODULES_H +#define __JE_COMMON_MODULES_H + +#define jin_undefined 0x00 + +#define jin_debug + +#define jin_os_windows 0x01 +#define jin_os_mac 0x02 +#define jin_os_linux 0x03 +#define jin_os jin_os_windows + +#define jin_graphics_font 0x02 +#define jin_graphics_shader 0x04 +#define jin_graphics_particle 0x08 +#define jin_graphics_animation 0x10 +#define jin_graphics (jin_graphics_font|jin_graphics_shader) + +#define jin_audio_sdl 0x01 +#define jin_audio_openal 0x02 +#define jin_audio jin_audio_sdl + +#define jin_filesystem_smount 0x01 +#define jin_filesystem jin_filesystem_smount + +#define jin_game + +#define jin_core + +#define jin_input_sdl 0x01 +#define jin_input jin_input_sdl + +#define jin_math + +#define jin_net_tekcos 0x01 +#define jin_net jin_net_tekcos + +#define jin_physics_newton 0x01 +#define jin_physics_box2d 0x02 +//#define jin_physics jin_physics_newton + +#define jin_thread_sdl 0x01 +#define jin_thread_cpp 0x02 +#define jin_thread_pthread 0x03 +#define jin_thread jin_thread_sdl + +#define jin_time_sdl 0x01 +#define jin_time_cpp 0x02 +#define jin_time jin_time_sdl + +#define jin_ai + +#endif // __JE_COMMON_MODULES_H
\ No newline at end of file diff --git a/src/libjin/Core/je_version.h b/src/libjin/Core/je_version.h new file mode 100644 index 0000000..77302c6 --- /dev/null +++ b/src/libjin/Core/je_version.h @@ -0,0 +1,52 @@ +#ifndef __JE_CORE_VERSION_H +#define __JE_CORE_VERSION_H + +namespace JinEngine +{ + namespace Core + { + + /// + /// Get version of Jin. + /// + /// @return Version of Jin. + /// + const char* getVersion() + { + return "Jin 0.1"; + } + + /// + /// Get author of Jin. + /// + /// @return Author of Jin. + /// + const char* getAuthor() + { + return "Chai"; + } + + /// + /// Get release of Jin. + /// + /// @return release string of Jin. + /// + const char* getRelease() + { + return "Jin 0.1.1"; + } + + /// + /// Get release of Jin. + /// + /// @return Revision of Jin. + /// + int getRevision() + { + return 101; + } + + } // namespace Core +} // namespace JinEngine + +#endif // __JE_CORE_VERSION_H
\ No newline at end of file |