Index: code/branches/WorldMap_HS18/src/orxonox/controllers/StoryModeController.cc
===================================================================
--- code/branches/WorldMap_HS18/src/orxonox/controllers/StoryModeController.cc	(revision 12131)
+++ code/branches/WorldMap_HS18/src/orxonox/controllers/StoryModeController.cc	(revision 12151)
@@ -21,5 +21,5 @@
  *
  *   Author:
- *      Fabian 'x3n' Landau
+ *      Joel Lingg
  *   Co-authors:
  *      ...
@@ -29,165 +29,142 @@
 #include "StoryModeController.h"
 
+namespace orxonox {
+  RegisterClass(StoryModeController);
 
-#include "core/CoreIncludes.h"
-#include "worldentities/ControllableEntity.h"
-#include "graphics/Camera.h"
-#include "SMCoord.h"
-#include "core/XMLPort.h"
-#include "gamestates/GSLevel.h"
-namespace orxonox
-{
-    RegisterClass(StoryModeController);
+  StoryModeController::StoryModeController(Context * context): SpaceShip(context) {
 
-   StoryModeController::StoryModeController(Context* context) : SpaceShip(context)
-    {
-        RegisterObject(StoryModeController);
-        float time_;
-        selectedPos_ = new SMCoord(0);
-        moveForward_= false;
-        moveBackward_=false;                     
-        boostPressed_=false;
-        dtime_=50;
+    RegisterObject(StoryModeController);
 
-      
-    }
-    StoryModeController::~StoryModeController()
-    {
-        delete selectedPos_;
-        selectedPos_ = nullptr;
+    //initiate all variables according to our needs
+    selectedPos_ = new SMCoord(0);
+    moveForward_ = false;
+    moveBackward_ = false;
+    boostPressed_ = false;
+    init_ = true;
+    dtime_ = 50;
+    time_ = dtime_ + 1;
+    updatePosition();
 
-    }
-    //void StoryModeController:: switchCamera(){};
-    void StoryModeController::updatePosition(){
-        Vector3 pos = selectedPos_->get3dcoordinate();
-        setPosition(pos);
-    }
-    void StoryModeController::setLocation(int index){
-         selectedPos_->set(index);
+  }
+  StoryModeController::~StoryModeController() {
+    delete selectedPos_;
+    selectedPos_ = nullptr;
+
+  }
+
+  //Pre:selectedPos_ needs to be defined
+  // Post: the position of the camera will be updated
+  void StoryModeController::updatePosition() {
+    Vector3 pos = selectedPos_ -> get3dcoordinate();
+    setPosition(pos);
+  }
+
+  //Pre: @index integer
+  //post: our new position is updated in selectedPos_
+  void StoryModeController::setLocation(int index) {
+    selectedPos_ -> set(index);
+  }
+
+  //Function which is repeated anz dt.
+  void StoryModeController::tick(float dt) {
+    //Passing arguments to SpaceShip
+    SUPER(StoryModeController, tick, dt);
+
+    Camera * camera = this -> getCamera();
+
+    if (init_ && camera != nullptr) {
+      camera -> setPosition(0, 0, 200);
+      camera -> setOrientation(Vector3::UNIT_Z, Degree(0));
+      init_ = false;
     }
 
-    void StoryModeController::tick(float dt)
-    {
-        //orxout(internal_error) << "Hi" << endl;
-        SUPER(StoryModeController, tick, dt);
-        time_ +=dt;
-           Camera* camera = this->getCamera();
-            
-       
+    //As I dont want to update positions every time (to prevent multiple key presses) time_ is raised untill a sertain dtime_
+    time_++;
+    if (time_ >= dtime_) {
 
-        if(time_>= dtime_*dt){
-            
-            time_=0;       
-         
-            if(moveForward_ == true){
-                orxout(internal_error) << "Position update" << endl; 
-                moveForward_ = false;
-                selectedPos_->set(selectedPos_->getIndex()+1);
-                updatePosition();
-            }
+      time_ = 0;
 
-            if(moveBackward_ == true){
-                orxout(internal_error) << "Position update" << endl; 
-                    moveBackward_ = false;
-                    selectedPos_->set(selectedPos_->getIndex()-1);
-                    updatePosition();
-               }
+      if (moveForward_ == true) {
+        moveForward_ = false;
+        selectedPos_ -> set(selectedPos_ -> getIndex() + 1);
+        updatePosition();
+      }
 
-               if(boostPressed_ == true){
-                    boostPressed_ = false;
-                    chooseGame();
-               }
+      if (moveBackward_ == true) {
+        moveBackward_ = false;
+        selectedPos_ -> set(selectedPos_ -> getIndex() - 1);
+        updatePosition();
+      }
 
-               
-             if (camera != nullptr)
-            {
+      if (boostPressed_ == true) {
+        boostPressed_ = false;
+        chooseGame();
+      }
 
-                Vector3 epos = selectedPos_->get3dcoordinate();
-                orxout(internal_error) << "ex: "<< epos.x <<" ey: "<< epos.y << " ez: " << epos.z<< endl;
-                camera->setPosition(-(epos.x),-(epos.y),-(epos.z)+1000);
-                camera->setOrientation(Vector3::UNIT_Z, Degree(0));
+      //updates the cameraposition
+      if (camera != nullptr) {
 
-            }
-       }
-       
+        camera -> setPosition(0, 0, 200);
+        camera -> setOrientation(Vector3::UNIT_Z, Degree(0));
+
+      }
     }
 
-    void StoryModeController::moveFrontBack(const Vector2& value)
-    {
-          // orxout(internal_error) << "moveFrontBack" << endl;          
+  }
+
+  //Post: The game is choosen acording to the index in selectedPos_. This one must be extended if more games want to be loaded
+  void StoryModeController::chooseGame() {
+    int ind = selectedPos_ -> getIndex();
+    std::string name = "changeGame ";
+    switch (ind) {
+    case 0:
+      name = name + "gallery.oxw";
+      break;
+    case 1:
+      name = name + "pong.oxw";
+      break;
+    case 2:
+      name = name + "towerDefense.oxw";
+      break;
+    case 3:
+      name = name + "SOB.oxw";
+      break;
+
+    default:
+      name = name + "MapExample.oxw";
+      break;
+    }
+    CommandExecutor::execute(name);
+
+  }
+
+  //decides if we move left or right
+  void StoryModeController::moveRightLeft(const Vector2 & value) {
+    if (!moveForward_ && !moveBackward_ && !boostPressed_) {
+      if (value.x > 0) {
+        moveForward_ = false;
+        moveBackward_ = true;
+      } else {
+        moveBackward_ = false;
+        moveForward_ = true;
+      }
     }
 
-    void StoryModeController::chooseGame()
-    {
-       int ind = selectedPos_->getIndex();
-       std::string name =   "changeGame ";
-       switch(ind){
-            case 0:
-            name = name + "pong.oxw";
-                break;
-            case 1:
-                
-                break;
-            case 2:
-                
-                break;
-            case 3:
-                
-                break;
-            case 4:
-                
-                break;
-            case 5:
-               
-                break;
-            case 6:
-                
-                break;
-            case 7:
-                
-                break;
-            case 8:
-               
-                break;
-            default:
-                break;    
-       }  
-       CommandExecutor::execute(name);
-       /*for (GSLevel* level : ObjectList<GSLevel>())
-            level->changeGame(name);*/
-       //hideAllMenuSheets();     
+  }
+
+  //decides to choose the game
+  void StoryModeController::boost(bool bBoost) {
+    if (!moveForward_ && !moveBackward_ && !boostPressed_) {
+      boostPressed_ = true;
     }
+  }
 
+  //Some functions I didn't use, but can be used to enhance your map. Just orientate at the function above
+  void StoryModeController::rotateYaw(const Vector2 & value) {}
+  void StoryModeController::rotatePitch(const Vector2 & value) {}
+  void StoryModeController::rotateRoll(const Vector2 & value) {}
+  void StoryModeController::moveFrontBack(const Vector2 & value) {}
+  void StoryModeController::fire(unsigned int a) {}
+  void StoryModeController::fired(unsigned int b) {}
 
-    void StoryModeController::moveRightLeft(const Vector2& value)
-    {
-        if(!moveForward_&&!moveBackward_){ 
-            if (value.x>0){
-                orxout(internal_error) << "Right" << endl;
-                moveForward_ =true;
-                moveBackward_ =false;
-            } else {
-                 orxout(internal_error) << "Left" << endl;
-                moveBackward_ = true;
-                moveForward_ = false;
-            }
-        }
-
-    }
-
-    void StoryModeController::rotateYaw(const Vector2& value){
-        //orxout(internal_error) << "RightLeft" << endl; 
-    }
-    void StoryModeController::rotatePitch(const Vector2& value){
-        //orxout(internal_error) << "RightLeft" << endl; 
-    }
-    void StoryModeController::rotateRoll(const Vector2& value){
-        //orxout(internal_error) << "RightLeft" << endl; 
-    }
-    void StoryModeController::fire(unsigned int a){}
-    void StoryModeController::fired(unsigned int b){}
-    void StoryModeController::boost(bool bBoost){
-        orxout(internal_error) << "Boost" << endl; 
-        boostPressed_ = true;
-    }
 }
