Index: code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.cc
===================================================================
--- code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.cc	(revision 11381)
+++ code/branches/SuperOrxoBros_FS17/src/modules/superorxobros/SOBFigure.cc	(revision 11383)
@@ -37,4 +37,5 @@
 #include "core/XMLPort.h"
 #include "graphics/Model.h"
+#include "graphics/Camera.h"
 
 
@@ -48,5 +49,5 @@
 
         // initialize variables
-      
+
         moveUpPressed_ = false;
         moveDownPressed_ = false;
@@ -55,7 +56,8 @@
         firePressed_ = false;
         timeSinceLastFire_ = 0.0;
-  
+        lastSpeed_z = 0.0;
+
         gravityAcceleration_ = 250.0;//8.0
-       
+
         dead_ = false;
         setAngularFactor(0.0);
@@ -65,5 +67,5 @@
     {
         SUPER(SOBFigure, XMLPort, xmlelement, mode);
-  
+
     }
 
@@ -74,67 +76,81 @@
         if (hasLocalController())
         {
-            timeSinceLastFire_ += dt;
-
-            // Move up/down
-            Vector3 velocity = getVelocity();
-          
-            
-            
-
-            
-
-       
-
-            // Move left/right
-            if (dead_ == false)
-            {
-
-                if (firePressed_ && std::abs(velocity.z) < 0.1) {
-                    velocity.z = 200;
-                } else {
-
-                }
-
-
-
-
-                if (moveRightPressed_)
-                    velocity.x = 75;
-                else if (moveLeftPressed_)
-                    velocity.x = -75;
-                else
-                    velocity.x = 0;
+          Vector3 velocity = getVelocity();
+          Vector3 position = getPosition();
+
+          if (dead_) {
+            velocity.x = 0;
+            velocity.z = 0;
+            setVelocity(velocity);
+            return;
+        }
+
+
+        int maxvelocity_x = 100;
+        int speedAddedPerTick = 5;
+        int camMaxOffset = 25;
+
+        timeSinceLastFire_ += dt;
+        lastSpeed_z = velocity.z;
+
+
+
+        //If player hits space and does not move in z-dir
+        if (firePressed_ && std::abs(velocity.z) < 0.07 && std::abs(lastSpeed_z) < 0.07) {
+            velocity.z = 150;
+        } 
+
+        //Left-right movement with acceleration
+        if (moveRightPressed_) {
+            if (std::abs(velocity.x) < maxvelocity_x) {
+                velocity.x += speedAddedPerTick;
             }
-            else
-            {
-                velocity.x = 0.0;
+        } else if (moveLeftPressed_) {
+            if (std::abs(velocity.x) < maxvelocity_x) {
+                velocity.x -= speedAddedPerTick;
             }
-                        velocity.z -= gravityAcceleration_*dt;
-
-           
-
-            setVelocity(velocity);
-
-
+        } else {
+            velocity.x /= 1.1;
+        } 
         
-        }
+
+        velocity.z -= gravityAcceleration_*dt;
+        setVelocity(velocity);
+
+
+        //Camera operation
+        Camera* cam = getCamera();
+        Vector3 campos = cam->getPosition();
+
+        if (campos.x + camMaxOffset < position.x) {
+            campos.x = position.x - camMaxOffset;
+            cam->setPosition(campos);
+        }
+           if (campos.x - camMaxOffset > position.x) {
+            campos.x = position.x + camMaxOffset;
+            cam->setPosition(campos);
+        }
+
+
+
+    }
 
         // Move through the left and right screen boundaries
-        
+
         //setPosition(position);
 
         // Reset key variables
-        moveUpPressed_ = false;
-        moveDownPressed_ = false;
-        moveLeftPressed_ = false;
-        moveRightPressed_ = false;
-        moveDownPressed_ = false;
-        firePressed_ = false;
-     
-    }
-
-   
-
-    
+    moveUpPressed_ = false;
+    moveDownPressed_ = false;
+    moveLeftPressed_ = false;
+    moveRightPressed_ = false;
+    moveDownPressed_ = false;
+    firePressed_ = false;
+
+}
+
+
+
+
 
    /* void SOBFigure::CollisionWithEnemy(SOBEnemy* enemy)
@@ -146,44 +162,44 @@
     }*/
 
-   
-
-
-    
-
-    void SOBFigure::moveFrontBack(const Vector2& value)
-    {
-        if (value.x > 0)
-        {
-            moveUpPressed_ = true;
-            moveDownPressed_ = false;
-        }
-        else
-        {
-            moveUpPressed_ = false;
-            moveDownPressed_ = true;
-        }
-    }
-
-    void SOBFigure::moveRightLeft(const Vector2& value)
-    {
-        if (value.x > 0)
-        {
-            moveLeftPressed_ = false;
-            moveRightPressed_ = true;
-        }
-        else
-        {
-            moveLeftPressed_ = true;
-            moveRightPressed_ = false;
-        }
-    }
-
-    
-
- 
-
-    void SOBFigure::boost(bool boost)
-        {
-        firePressed_ = true;
-    }
-}
+
+
+
+
+
+void SOBFigure::moveFrontBack(const Vector2& value)
+{
+    if (value.x > 0)
+    {
+        moveUpPressed_ = true;
+        moveDownPressed_ = false;
+    }
+    else
+    {
+        moveUpPressed_ = false;
+        moveDownPressed_ = true;
+    }
+}
+
+void SOBFigure::moveRightLeft(const Vector2& value)
+{
+    if (value.x > 0)
+    {
+        moveLeftPressed_ = false;
+        moveRightPressed_ = true;
+    }
+    else
+    {
+        moveLeftPressed_ = true;
+        moveRightPressed_ = false;
+    }
+}
+
+
+
+
+
+void SOBFigure::boost(bool boost)
+{
+    firePressed_ = true;
+}
+}
