summaryrefslogtreecommitdiff
path: root/src/interface/Engine.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-01-15 19:35:40 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-01-15 19:35:40 (GMT)
commit2511afec8bfaa0582928406b37e8b579fa267e4f (patch)
treeaae1674f5f076db275ec1c6b32271a69cff1489a /src/interface/Engine.cpp
parent2c9295007a287dc01ff63fcf7b3da141f7474e37 (diff)
downloadpowder-2511afec8bfaa0582928406b37e8b579fa267e4f.zip
powder-2511afec8bfaa0582928406b37e8b579fa267e4f.tar.gz
More stuff, better events and starting on interface
Diffstat (limited to 'src/interface/Engine.cpp')
-rw-r--r--src/interface/Engine.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/src/interface/Engine.cpp b/src/interface/Engine.cpp
index 4468561..25f2038 100644
--- a/src/interface/Engine.cpp
+++ b/src/interface/Engine.cpp
@@ -1,3 +1,7 @@
+#include <iostream>
+
+#include "Config.h"
+#include "Global.h"
#include "interface/Platform.h"
#include "interface/Engine.h"
#include "interface/State.h"
@@ -5,15 +9,14 @@
using namespace ui;
-Engine::Engine()
-:
- g(NULL),
-state_(NULL),
-statequeued_(NULL),
-mousex_(0),
-mousey_(0),
-mousexp_(0),
-mouseyp_(0)
+Engine::Engine():
+ state_(NULL),
+ statequeued_(NULL),
+ mousex_(0),
+ mousey_(0),
+ mousexp_(0),
+ mouseyp_(0),
+ FpsLimit(60.0f)
{
}
@@ -23,10 +26,8 @@ Engine::~Engine()
delete state_;
}
-void Engine::Begin(int width, int height, SDL_Surface * surface)
+void Engine::Begin(int width, int height)
{
- g = new Graphics();
- g->AttachSDLSurface(surface);
//engine is now ready
running_ = true;
@@ -82,8 +83,8 @@ void Engine::Draw()
{
if(state_)
state_->DoDraw();
- g->Blit();
- g->Clear();
+ Global::Ref().g->Blit();
+ Global::Ref().g->Clear();
}
void Engine::onKeyPress(int key, bool shift, bool ctrl, bool alt)
@@ -115,7 +116,9 @@ void Engine::onMouseMove(int x, int y)
mousex_ = x;
mousey_ = y;
if(state_)
+ {
state_->DoMouseMove(x, y, mousex_ - mousexp_, mousey_ - mouseyp_);
+ }
mousexp_ = x;
mouseyp_ = y;
}