summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 422fdc3..d059b75 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -5,6 +5,7 @@
#include "renderer.h"
#include "window.h"
#include "timer.h"
+#include "keyHandler.h"
#include <chrono>
#include <thread>
@@ -96,26 +97,23 @@ main( int argc, char* args[] ) {
const Uint32 LOOP_TIME = 20L; // milliseconds
Timer timer;
timer.start();
+
+ GameState game;
+ KeyHandler keys;
+
while( true )
{
// Handle events
SDL_Event e;
while( SDL_PollEvent( &e ) != 0 )
{
- //User requests quit
- window.handleEvent(e);
- if( e.type == SDL_QUIT ) {
- return 0;
- } else if (e.type == SDL_KEYDOWN){
- switch( e.key.keysym.sym ){
- case 'q':
- return 0;
- }
- }
+ // Maybe add commands in a queue or a better defined stream?
+ window.handleEvent(e)->execute(game);
+ keys.handleEvent(e)->execute(game);
}
- if(window.closed()) return 0;
- if(!window.focused()) goto next;
+ if(game.isClosed()) return 0;
+ if(game.isPaused()) goto next;
// GAME LOOP: