summaryrefslogtreecommitdiffstats
path: root/src/rpgedit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/rpgedit.cpp')
-rw-r--r--src/rpgedit.cpp69
1 files changed, 2 insertions, 67 deletions
diff --git a/src/rpgedit.cpp b/src/rpgedit.cpp
index 4efaf10..6ef5dd3 100644
--- a/src/rpgedit.cpp
+++ b/src/rpgedit.cpp
@@ -24,82 +24,17 @@
*/
-#include "control/EventBus.hpp"
-#include "control/InputHandler.hpp"
-#include "control/MapContext.hpp"
-#include "view/MapView.hpp"
-
-#include <unistd.h>
+#include "control/RPGEdit.hpp"
#include <SDL.h>
#include <SDL_main.h>
-#define MIN_FRAME_DELAY 10
-
-
extern "C"
int main(__attribute__((unused)) int argc, __attribute__((unused)) char *argv[]) {
- using namespace RPGEdit;
-
SDL_Init(SDL_INIT_VIDEO);
- {
- Control::EventBus eventBus;
-
- Control::InputHandler inputHandler;
-
- Control::ImageLoader tileLoader;
- std::shared_ptr<Model::Map> map = Model::Map::load("test");
-
- std::shared_ptr<Control::MapContext> ctx(new Control::MapContext(&tileLoader, map));
-
- std::shared_ptr<View::Window> window(new View::Window);
- std::shared_ptr<View::MapView> mapView = ctx->initView(window);
-
- bool running = true;
- uint32_t ticks = SDL_GetTicks();
- uint32_t lastFrameTicks = ticks;
-
- while (true) {
- int timeout = lastFrameTicks + MIN_FRAME_DELAY - SDL_GetTicks();
- if (timeout < 0)
- timeout = 0;
-
- SDL_Event event;
- if (SDL_WaitEventTimeout(&event, timeout)) {
- switch (event.type) {
- case SDL_KEYDOWN:
- inputHandler.keyPressed(event.key.keysym.scancode);
- break;
-
- case SDL_KEYUP:
- inputHandler.keyReleased(event.key.keysym.scancode);
- break;
-
- case SDL_QUIT:
- running = false;
- break;
- }
- }
-
- if (!running)
- break;
-
- uint32_t newTicks = SDL_GetTicks();
- ctx->advance(&inputHandler, newTicks - ticks);
-
- ticks = newTicks;
-
- if (!SDL_TICKS_PASSED(SDL_GetTicks(), lastFrameTicks + MIN_FRAME_DELAY))
- continue;
-
- Model::Position pos = map->getPlayerEntity().getPosition();
- mapView->render(pos.x, pos.y);
-
- lastFrameTicks = ticks;
- }
- }
+ RPGEdit::Control::RPGEdit().run();
SDL_Quit();