summaryrefslogtreecommitdiff
path: root/src/game/GameController.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-01-17 20:46:06 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-01-17 20:46:06 (GMT)
commit4a60b97c700c2f1843b7e99313554cb89fb5da4e (patch)
tree3b33ef6f74a4e8a4ff5968a81b9c4c429ccaa7c6 /src/game/GameController.cpp
parent6273089bf486bf46ad325d72c7290ebb272bd3d8 (diff)
downloadpowder-4a60b97c700c2f1843b7e99313554cb89fb5da4e.zip
powder-4a60b97c700c2f1843b7e99313554cb89fb5da4e.tar.gz
Some minor changes
Diffstat (limited to 'src/game/GameController.cpp')
-rw-r--r--src/game/GameController.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp
new file mode 100644
index 0000000..becb540
--- /dev/null
+++ b/src/game/GameController.cpp
@@ -0,0 +1,62 @@
+
+#include <iostream>
+#include <queue>
+#include "Config.h"
+#include "GameController.h"
+#include "GameModel.h"
+#include "interface/Point.h"
+
+using namespace std;
+
+GameController::GameController()
+{
+ gameView = new GameView();
+ gameModel = new GameModel();
+
+ gameView->AttachController(this);
+ gameModel->AddObserver(gameView);
+
+ sim = new Simulation();
+}
+
+GameView * GameController::GetView()
+{
+ return gameView;
+}
+
+void GameController::DrawPoints(queue<ui::Point*> & pointQueue)
+{
+ Simulation * sim = gameModel->GetSimulation();
+ int activeElement = gameModel->GetActiveElement();
+ if(!pointQueue.empty())
+ {
+ ui::Point * sPoint = NULL;
+ while(!pointQueue.empty())
+ {
+ ui::Point * fPoint = pointQueue.front();
+ pointQueue.pop();
+ if(sPoint)
+ {
+ sim->create_line(fPoint->X, fPoint->Y, sPoint->X, sPoint->Y, 1, 1, activeElement, 0);
+ delete sPoint;
+ }
+ else
+ {
+ sim->create_parts(fPoint->X, fPoint->Y, 1, 1, activeElement, 0);
+ }
+ sPoint = fPoint;
+ }
+ if(sPoint)
+ delete sPoint;
+ }
+}
+
+void GameController::Tick()
+{
+ gameModel->GetSimulation()->update_particles();
+}
+
+void GameController::SetPaused(bool pauseState)
+{
+ gameModel->SetPaused(pauseState);
+}