Index: de/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongAI.cc
===================================================================
--- /code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongAI.cc	(revision 12247)
+++ 	(revision )
@@ -1,385 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-    @file PongAI.cc
-    @brief Implementation of the PongAI class.
-*/
-
-#include "PongAI.h"
-
-#include "core/CoreIncludes.h"
-#include "core/config/ConfigValueIncludes.h"
-#include "core/command/Executor.h"
-#include "tools/Timer.h"
-
-#include "worldentities/ControllableEntity.h"
-
-#include "PongBall.h"
-
-namespace orxonox
-{
-    RegisterUnloadableClass(PongAI);
-
-    const static float MAX_REACTION_TIME = 0.4f;
-
-    /**
-    @brief
-        Constructor. Registers and initializes the object.
-    */
-    PongAI::PongAI(Context* context) : Controller(context)
-    {
-        RegisterObject(PongAI);
-
-        this->ball_ = nullptr;
-        this->ballDirection_ = Vector2::ZERO;
-        this->ballEndPosition_ = 0;
-        this->randomOffset_ = 0;
-        this->bChangedRandomOffset_ = false;
-        this->relHysteresisOffset_ = 0.02f;
-        this->strength_ = 0.5f;
-        this->movement_ = 0;
-        this->oldMove_ = 0;
-        this->bOscillationAvoidanceActive_ = false;
-
-        this->setConfigValues();
-    }
-
-    /**
-    @brief
-        Destructor. Cleans up the list fo reaction timers.
-    */
-    PongAI::~PongAI()
-    {
-        for (std::pair<Timer*, char>& pair : this->reactionTimers_)
-            delete pair.first;
-    }
-
-    /**
-    @brief
-        Sets config values.
-    */
-    void PongAI::setConfigValues()
-    {
-        // Sets the strength of the PongAi as a config value.
-        SetConfigValue(strength_, 0.5).description("A value from 0 to 1 where 0 is weak and 1 is strong.");
-    }
-
-    /**
-    @brief
-        Is called each tick.
-        Implements the behavior of the PongAI (i.e. its intelligence).
-    @param dt
-        The time that has elapsed since the last tick.
-    */
-    void PongAI::tick(float dt)
-    {
-        // If either the ball, or the controllable entity (i.e. the bat) don't exist (or aren't set).
-        if (this->ball_  == nullptr || this->getControllableEntity() == nullptr)
-            return;
-
-        Vector3 mypos = this->getControllableEntity()->getPosition();
-        Vector3 ballpos = this->ball_->getPosition();
-        Vector3 ballvel = this->ball_->getVelocity();
-        float hysteresisOffset = this->relHysteresisOffset_ * this->ball_->getFieldDimension().y;
-
-        char move = 0;
-        bool delay = false;
-
-        // Check in which direction the ball is flying
-        if ((mypos.x > 0 && ballvel.x < 0) || (mypos.x < 0 && ballvel.x > 0))
-        {
-            // The ball is flying away
-            this->ballDirection_.x = -1;
-            this->ballDirection_.y = 0;
-            this->bOscillationAvoidanceActive_ = false;
-
-            // Move to the middle
-            if (mypos.z > hysteresisOffset)
-                move = 1;
-            else if (mypos.z < -hysteresisOffset)
-                move = -1;
-        }
-        else if (ballvel.x == 0)
-        {
-            // The ball is standing still
-            this->ballDirection_.x = 0;
-            this->ballDirection_.y = 0;
-            this->bOscillationAvoidanceActive_ = false;
-        }
-        else
-        {
-            // The ball is approaching
-            if (this->ballDirection_.x != 1)
-            {
-                // The ball just started to approach, initialize all values
-                this->ballDirection_.x = 1;
-                this->ballDirection_.y = sgn(ballvel.z);
-                this->ballEndPosition_ = 0;
-                this->randomOffset_ = 0;
-                this->bChangedRandomOffset_ = false;
-
-                this->calculateRandomOffset();
-                this->calculateBallEndPosition();
-                delay = true;
-                this->bOscillationAvoidanceActive_ = false;
-            }
-
-            if (this->ballDirection_.y != sgn(ballvel.z))
-            {
-                // The ball just bounced from a bound, recalculate the predicted end position
-                this->ballDirection_.y = sgn(ballvel.z);
-
-                this->calculateBallEndPosition();
-                delay = true;
-                this->bOscillationAvoidanceActive_ = false;
-            }
-
-            // If the ball is close enough, calculate another random offset to accelerate the ball
-            if (!this->bChangedRandomOffset_)
-            {
-                float timetohit = (-ballpos.x + this->ball_->getFieldDimension().x / 2 * sgn(ballvel.x)) / ballvel.x;
-                if (timetohit < 0.05)
-                {
-                    this->bChangedRandomOffset_ = true;
-                    if (rnd() < this->strength_)
-                        this->calculateRandomOffset();
-                }
-            }
-
-            // Move to the predicted end position with an additional offset (to hit the ball with the side of the bat)
-            if (!this->bOscillationAvoidanceActive_)
-            {
-                float desiredZValue = this->ballEndPosition_ + this->randomOffset_;
-
-                if (mypos.z > desiredZValue + hysteresisOffset * (this->randomOffset_ < 0))
-                    move = 1;
-                else if (mypos.z < desiredZValue - hysteresisOffset * (this->randomOffset_ > 0))
-                    move = -1;
-            }
-
-            if (move != 0 && this->oldMove_ != 0 && move != this->oldMove_ && !delay)
-            {
-                // We had to correct our position because we moved too far
-                // (and delay is false, so we're not in the wrong place because of a new end-position prediction)
-                if (fabs(mypos.z - this->ballEndPosition_) < 0.5 * this->ball_->getBatLength() * this->ball_->getFieldDimension().y)
-                {
-                    // We're not at the right position, but we still hit the ball, so just stay there to avoid oscillation
-                    move = 0;
-                    this->bOscillationAvoidanceActive_ = true;
-                }
-            }
-        }
-
-        this->oldMove_ = move;
-        this->move(move, delay);
-        this->getControllableEntity()->moveFrontBack(this->movement_);
-    }
-
-    /**
-    @brief
-        Calculates the random offset, that accounts for random errors the AI makes in order to be beatable.
-        The higher the strength of the AI, the smaller the (expected value of the) error.
-        The result of this method is stored in this->randomOffset_.
-    */
-    void PongAI::calculateRandomOffset()
-    {
-        // Calculate the exponent for the position-formula
-        float exp = pow(10.0f, 1.0f - 2.0f*this->strength_); // strength: 0   -> exp = 10
-                                                             // strength: 0.5 -> exp = 1
-                                                             // strength: 1   -> exp = 0.1
-
-        // Calculate the relative position where to hit the ball with the bat
-        float position = pow(rnd(), exp); // exp > 1 -> position is more likely a small number
-                                          // exp < 1 -> position is more likely a large number
-
-        // The position shouldn't be larger than 0.5 (50% of the bat-length from the middle is the end)
-        position *= 0.48f;
-
-        // Both sides are equally probable
-        position *= rndsgn();
-
-        // Calculate the offset in world units
-        this->randomOffset_ = position * this->ball_->getBatLength() * this->ball_->getFieldDimension().y;
-    }
-
-    /**
-    @brief
-        Calculate the end position the ball will be in.
-        The result of this calculation is stored in this->ballEndPosition_.
-    */
-    void PongAI::calculateBallEndPosition()
-    {
-        Vector3 position = this->ball_->getPosition();
-        Vector3 velocity = this->ball_->getVelocity();
-        Vector3 acceleration = this->ball_->getAcceleration();
-        Vector2 dimension = this->ball_->getFieldDimension();
-
-        // Calculate bounces. The number of predicted bounces is limited by the AIs strength
-        for (float limit = -0.05f; limit < this->strength_ || this->strength_ > 0.99f; limit += 0.4f)
-        {
-            // calculate the time until the ball reaches the other side
-            float totaltime = (-position.x + dimension.x / 2 * sgn(velocity.x)) / velocity.x;
-
-            // calculate wall bounce position (four possible solutions of the equation: pos.z + vel.z*t + acc.z/2*t^2 = +/- dim.z/2)
-            float bouncetime = totaltime;
-            bool bUpperWall = false;
-
-            if (acceleration.z == 0)
-            {
-                if (velocity.z > 0)
-                {
-                    bUpperWall = true;
-                    bouncetime = (dimension.y/2 - position.z) / velocity.z;
-                }
-                else if (velocity.z < 0)
-                {
-                    bUpperWall = false;
-                    bouncetime = (-dimension.y/2 - position.z) / velocity.z;
-                }
-            }
-            else
-            {
-                // upper wall
-                float temp = velocity.z*velocity.z + 2*acceleration.z*(dimension.y/2 - position.z);
-                if (temp >= 0)
-                {
-                    float t1 = (sqrt(temp) - velocity.z) / acceleration.z;
-                    float t2 = (sqrt(temp) + velocity.z) / acceleration.z * (-1);
-                    if (t1 > 0 && t1 < bouncetime)
-                    {
-                        bouncetime = t1;
-                        bUpperWall = true;
-                    }
-                    if (t2 > 0 && t2 < bouncetime)
-                    {
-                        bouncetime = t2;
-                        bUpperWall = true;
-                    }
-                }
-                // lower wall
-                temp = velocity.z*velocity.z - 2*acceleration.z*(dimension.y/2 + position.z);
-                if (temp >= 0)
-                {
-                    float t1 = (sqrt(temp) - velocity.z) / acceleration.z;
-                    float t2 = (sqrt(temp) + velocity.z) / acceleration.z * (-1);
-                    if (t1 > 0 && t1 < bouncetime)
-                    {
-                        bouncetime = t1;
-                        bUpperWall = false;
-                    }
-                    if (t2 > 0 && t2 < bouncetime)
-                    {
-                        bouncetime = t2;
-                        bUpperWall = false;
-                    }
-                }
-            }
-
-            if (bouncetime < totaltime)
-            {
-                // Calculate a random prediction error, based on the vertical speed of the ball and the strength of the AI
-                float randomErrorX = rnd(-1, 1) * dimension.y * (velocity.z / velocity.x / PongBall::MAX_REL_Z_VELOCITY) * (1 - this->strength_);
-                float randomErrorZ = rnd(-1, 1) * dimension.y * (velocity.z / velocity.x / PongBall::MAX_REL_Z_VELOCITY) * (1 - this->strength_);
-
-                // ball bounces after <bouncetime> seconds, update the position and continue
-                velocity.z = velocity.z + acceleration.z * bouncetime;
-
-                if (bUpperWall)
-                {
-                    position.z = dimension.y / 2;
-                    velocity.z = -fabs(velocity.z) + fabs(randomErrorZ);
-                }
-                else
-                {
-                    position.z = -dimension.y / 2;
-                    velocity.z = fabs(velocity.z) - fabs(randomErrorZ);
-                }
-
-                position.x = position.x + velocity.x * bouncetime + randomErrorX;
-                this->ballEndPosition_ = position.z;
-            }
-            else
-            {
-                // ball doesn't bounce, calculate the end position and return
-                // calculate end-height: current height + slope * distance incl. acceleration
-                this->ballEndPosition_ = position.z + velocity.z * totaltime + acceleration.z / 2 * totaltime * totaltime;
-                return;
-            }
-        }
-    }
-
-    /**
-    @brief
-        Determine the movement the AI will undertake. (Either -1, 0 or 1)
-        The result of this calculation is stored in this->movement_;
-    @param direction
-        The current direction of movement.
-    @param bUseDelay
-        The time by which this move is delayed. (Again, to make the AI less efficient)
-    */
-    void PongAI::move(char direction, bool bUseDelay)
-    {
-        // The current direction is either what we're doing right now (movement_) or what is last in the queue
-        char currentDirection = this->movement_;
-        if (this->reactionTimers_.size() > 0)
-            currentDirection = this->reactionTimers_.back().second;
-
-        // Only add changes of direction
-        if (direction == currentDirection)
-            return;
-
-        if (bUseDelay)
-        {
-            // Calculate delay
-            float delay = MAX_REACTION_TIME * (1 - this->strength_);
-
-            // Add a new Timer
-            Timer* timer = new Timer(delay, false, createExecutor(createFunctor(&PongAI::delayedMove, this)));
-            this->reactionTimers_.emplace_back(timer, direction);
-        }
-        else
-        {
-            this->movement_ = direction;
-        }
-    }
-
-    /**
-    @brief
-        Is called, when a delayed move takes effect.
-    */
-    void PongAI::delayedMove()
-    {
-        // Get the new movement direction from the timer list
-        this->movement_ = this->reactionTimers_.front().second;
-
-        // Destroy the timer and remove it from the list
-        delete this->reactionTimers_.front().first;
-        this->reactionTimers_.pop_front();
-    }
-}
Index: de/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongAI.h
===================================================================
--- /code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/PongAI.h	(revision 12247)
+++ 	(revision )
@@ -1,98 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-    @file PongAI.h
-    @brief Declaration of the PongAI class.
-    @ingroup Pong
-*/
-
-#ifndef _PongAI_H__
-#define _PongAI_H__
-
-#include "pong/PongPrereqs.h"
-
-#include <list>
-
-#include "util/Math.h"
-#include "tools/interfaces/Tickable.h"
-
-#include "controllers/Controller.h"
-#include "PongBall.h"
-
-namespace orxonox
-{
-
-    /**
-    @brief
-        The PongAI is an artificial intelligence for the @ref orxonox::Pong "Pong" gametype.
-
-    @author
-        Fabian 'x3n' Landau
-
-    @ingroup Pong
-    */
-    class _PongExport PongAI : public Controller, public Tickable
-    {
-        public:
-            PongAI(Context* context); //!< Constructor. Registers and initializes the object.
-            virtual ~PongAI();
-
-            void setConfigValues();
-
-            virtual void tick(float dt) override; //!< Implements the behavior of the PongAI (i.e. its intelligence).
-
-            /**
-            @brief Set the ball for the AI.
-            @param ball A pointer to the ball.
-            */
-            void setPongBall(PongBall* ball)
-                { this->ball_ = ball; }
-
-        protected:
-            void calculateRandomOffset(); //!< Calculates the random offset, that accounts for random errors the AI makes in order to be beatable.
-            void calculateBallEndPosition(); //!< Calculate the end position the ball will be in.
-            void move(char direction, bool bUseDelay); //!< Determine the movement the AI will undertake.
-            void delayedMove(); //!< Is called, when a delayed move takes effect.
-
-            WeakPtr<PongBall> ball_; //!< A weak pointer to the ball.
-            Vector2 ballDirection_; //!< Vector to store the (x,z) direction in which the ball is flying.
-            float ballEndPosition_; //!< The calculated end position of the ball.
-            float randomOffset_; //!< A random offset to introduce random errors (weighted by the strength of the AI) into the AI's behavior.
-            bool bChangedRandomOffset_; //!< Helper boolean, to change the random offset more often.
-            float relHysteresisOffset_; //!< A hysteresis offset.
-            float strength_; //!< The strength of the AI. Ranging from 0 to 1.
-
-            std::list<std::pair<Timer*, char>> reactionTimers_; //!< A list of reaction timers and the directions that take effect when their timer expires.
-            char movement_; //!< The planned movement.
-            char oldMove_; //!< The previous movement.
-            bool bOscillationAvoidanceActive_; //!< Boolean, to avoid oscillations.
-    };
-}
-
-#endif /* _PongAI_H__ */
Index: /code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/TempData/OrxoBloxBall.cc
===================================================================
--- /code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/TempData/OrxoBloxBall.cc	(revision 12248)
+++ /code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/TempData/OrxoBloxBall.cc	(revision 12248)
@@ -0,0 +1,347 @@
+
+//TODO: Sounds (all the sounds are still from the OrxoBlox module...)
+//TODO: Blocks (the Ball-Block comunication is based on how the blocks are implemented)
+//TODO: The bottom boundary/ the Ball collecter
+//TODO: Ability to shoot the ball (the ball is still constructed like the OrxoBlox ball)
+
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file OrxoBloxBall.cc
+    @brief Implementation of the OrxoBloxBall class.
+*/
+
+#include "OrxoBloxBall.h"
+
+#include "core/CoreIncludes.h"
+#include "core/GameMode.h"
+
+#include "gametypes/Gametype.h"
+
+#include "OrxoBloxBlocks.h"
+
+#include "sound/WorldSound.h"
+#include "core/XMLPort.h"
+
+namespace orxonox
+{
+    RegisterClass(OrxoBloxBall);
+
+    const float OrxoBloxBall::MAX_REL_Z_VELOCITY = 1.5;
+
+    /**
+    @brief
+        Constructor. Registers and initializes the object.
+    */
+    OrxoBloxBall::OrxoBloxBall(Context* context)
+        : MovableEntity(context)
+    {
+        RegisterObject(OrxoBloxBall);
+
+        this->speed_ = 0;
+        //NUMBER OF BLOCKS IS A CONSTANT AT THE MOMENT, DYNAMICAL IMPLEMENTATION WOULD BE NICE
+        this->nblocks_ = 20;                                            //number of blocks on the field
+        this->blocks_ = new OrxoBloxStone[this.nblocks_];               //the blocks in a block array
+        this->fieldWidth_ = 100;
+        this->fieldHeight_ = 100;
+
+        this->registerVariables();
+
+        //initialize sound
+        if (GameMode::isMaster())
+             {
+                 this->defBoundarySound_ = new WorldSound(this->getContext());
+                 this->defBoundarySound_->setVolume(0.5f);
+             }
+             else
+             {
+                 this->defBoundarySound_ = nullptr;
+             }
+    }
+
+    /**
+    @brief
+        Destructor.
+    */
+    OrxoBloxBall::~OrxoBloxBall()
+    {
+        this.destroy();
+    }
+
+    //xml port for loading sounds
+    void OrxoBloxBall::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(OrxoBloxBall, XMLPort, xmlelement, mode);
+        XMLPortParam(OrxoBloxBall, "defBoundarySound",  setDefBoundarySound,  getDefBoundarySound,  xmlelement, mode);
+    }
+
+    /**
+    @brief
+        Register variables to synchronize over the network.
+    */
+    void OrxoBloxBall::registerVariables()
+    {
+        registerVariable( this->fieldWidth_ );
+        registerVariable( this->fieldHeight_ );
+        registerVariable( this->speed_ );
+        registerVariable( this->nblocks_ );
+        registerVariable( this->blocks_ );
+    }
+
+    /**
+    @brief
+        Is called every tick.
+        Handles the movement of the ball and its interaction with the boundaries and blocks.
+    @param dt
+        The time since the last tick.
+    */
+    void OrxoBloxBall::tick(float dt)
+    {
+        SUPER(OrxoBloxBall, tick, dt);
+
+        // Get the current position, velocity and acceleration of the ball.
+        Vector3 position = this->getPosition();
+        Vector3 velocity = this->getVelocity();
+        Vector3 acceleration = this->getAcceleration();
+
+        // If the ball has hit the boundaries on either the right side or the left 
+        if (position.x > this->fieldWidth_  || position.x < 0)
+        {
+            defBoundarySound_->play(); //play boundary sound
+            // Its velocity in x-direction is inverted (i.e. it bounces off).
+            velocity.x = -velocity.x;
+            // And its position is set as to not overstep the boundary it has just crossed.
+            if (position.x > this->fieldWidth_)
+                position.x = this->fieldWidth_;
+            else if (position.x < 0)
+                position.x = 0;
+
+            this->fireEvent();
+        }
+
+	   // If the ball has hit the boundary on the top
+        if (position.y > this->fieldHeight_)
+        {
+            defBoundarySound_->play(); //play boundary sound
+            // Its velocity in z-direction is inverted (i.e. it bounces off).
+            velocity.y = -velocity.y;
+            // And its position is set as to not overstep the boundary it has just crossed.
+            position.y = this->fieldHeight_;
+
+            this->fireEvent();
+        }
+
+        //If the ball collides with a block
+        for (int i = 0; i < this.nblocks_ ; i++) {
+
+            if (
+                (-position.x + this->blocks[i]_.getLeft())      < 0 ||
+                (position.x - this->blocks[i]_.getRight())      < 0 ||
+                (-position.y + this->blocks[i]_.getBottom())    < 0 ||
+                (position.y - this->blocks[i]_.getTop())        < 0
+            ) {
+                int dist_left = position.x - this->blocks[i]_.getLeft();
+                int dist_right = -position.x + this->blocks[i]_.getRight();
+                int dist_bot = position.y - this->blocks[i]_.getBottom();
+                int dist top = -position.y + this->blocks[i]_.getTop();
+
+                if (dist_left < dist_right){
+                    if(dist_left < dist_top && dist_left < dist_bot) {
+                        defBoundarySound_->play();
+                        velocity.x = -velocity.x;
+                        position.x = this->blocks[i]_.getLeft();
+
+                    }
+                    else if(dist_left == dist_top) {
+                        defBoundarySound_->play();
+                        velocity.x = -velocity.x;
+                        velocity.y = -velocity.y;
+                        position.x = this->blocks[i]_.getLeft();
+                        position.y = this->blocks[i]_.getTop();
+                    }
+                    else if(dist_left == dist_bot) {
+                        defBoundarySound_->play();
+                        velocity.x = -velocity.x;
+                        velocity.y = -velocity.y;
+                        position.x = this->blocks[i]_.getLeft();
+                        position.y = this->blocks[i]_.getBot();
+                    }
+                }
+                else if (dist_right < dist_left){
+                    if(dist_right < dist_top && dist_left < dist_bot) {
+                        defBoundarySound_->play();
+                        velocity.x = -velocity.x;
+                        position.x = this->blocks[i]_.getRight();
+
+                    }
+                    else if(dist_right == dist_top) {
+                        defBoundarySound_->play();
+                        velocity.x = -velocity.x;
+                        velocity.y = -velocity.y;
+                        position.x = this->blocks[i]_.getRight();
+                        position.y = this->blocks[i]_.getTop();
+                    }
+                    else if(dist_right == dist_bot) {
+                        defBoundarySound_->play();
+                        velocity.x = -velocity.x;
+                        velocity.y = -velocity.y;
+                        position.x = this->blocks[i]_.getRight();
+                        position.y = this->blocks[i]_.getBot();
+                    }
+                }
+                else if (dist_bot < dist_top){
+                    if(dist_bot < dist_left && dist_bot < dist_right) {
+                        defBoundarySound_->play();
+                        velocity.y = -velocity.y;
+                        position.y = this->blocks[i]_.getBot();
+
+                    }
+                    else if(dist_bot == dist_left) {
+                        defBoundarySound_->play();
+                        velocity.x = -velocity.x;
+                        velocity.y = -velocity.y;
+                        position.x = this->blocks[i]_.getLeft();
+                        position.y = this->blocks[i]_.getBot();
+                    }
+                    else if(dist_bot == dist_right) {
+                        defBoundarySound_->play();
+                        velocity.x = -velocity.x;
+                        velocity.y = -velocity.y;
+                        position.x = this->blocks[i]_.getRight();
+                        position.y = this->blocks[i]_.getBot();
+                    }
+                }
+                else if (dist_top bot){
+                    if(dist_top < dist_left && dist_top < dist_right) {
+                        defBoundarySound_->play();
+                        velocity.y = -velocity.y;
+                        position.y = this->blocks[i]_.getBot();
+
+                    }
+                    else if(dist_top == dist_left) {
+                        defBoundarySound_->play();
+                        velocity.x = -velocity.x;
+                        velocity.y = -velocity.y;
+                        position.x = this->blocks[i]_.getLeft();
+                        position.y = this->blocks[i]_.getTop();
+                    }
+                    else if(dist_top == dist_right) {
+                        defBoundarySound_->play();
+                        velocity.x = -velocity.x;
+                        velocity.y = -velocity.y;
+                        position.x = this->blocks[i]_.getRight();
+                        position.y = this->blocks[i]_.getTop();
+                    }
+                }
+                this->blocks[i]_.gotHit()
+                this->fireEvent();
+            }
+        } 
+
+        // If the ball has crossed the bottom boundary
+        if (position.y < 0)
+        {
+            ~OrxoBloxBall();
+	//TODO: THE BALLS NEED TO BE COLLECTED, DESTROYED AND COUNTED... NEW SHOOTING POSITION NEEDS TO BE SET
+        }
+
+        // Set the position, velocity and acceleration of the ball, if they have changed.
+        if (acceleration != this->getAcceleration())
+            this->setAcceleration(acceleration);
+        if (velocity != this->getVelocity())
+            this->setVelocity(velocity);
+        if (position != this->getPosition())
+            this->setPosition(position);
+    }
+
+    /**
+    @brief
+        Set the speed of the ball (in x,y-direction).
+    @param speed
+        The speed to be set.
+    */
+    void OrxoBloxBall::setSpeed(float speed)
+    {
+        if (speed != this->speed_) // If the speed changes
+        {
+            this->speed_ = speed;
+
+            // Set the speed in the direction of the balls current velocity.
+            Vector3 velocity = this->getVelocity();
+            if (velocity.y != 0)
+                velocity.y = sgn(velocity.y) * this->speed_;
+            else // If the balls current velocity is zero, the speed is set in a random direction.
+                velocity.y = this->speed_ * sgn(rnd(-1,1));
+
+            if (velocity.x != 0)
+                velocity.x = sgn(velocity.x) * this->speed_;
+            else // If the balls current velocity is zero, the speed is set in a random direction.
+                velocity.x = this->speed_ * sgn(rnd(-1,1));
+
+            this->setVelocity(velocity);
+        }
+    }
+
+    /**
+    @brief
+        Set the blocks for the ball.
+    @param bats
+        An array (of size n (n=#Blocks) of weak pointers, to be set as the new blocks.
+    */
+    void OrxoBloxBall::setBlock(OrxoBloxStone[] blocks, int n)
+    {
+        if(n > this.nblocks_) {
+            this.nblocks = n;
+            delete this.blocks_;
+            this.nblocks_ = new OrxoBloxStone[this.nblocks_];
+        } 
+	   for (int i = 0; i < n; i++) {
+        	this->blocks_[i] = blocks[i];
+	   }
+    }
+
+    void OrxoBloxBall::setDefBoundarySound(const std::string &OrxoBloxSound)
+    {
+        if( defBoundarySound_ )
+            defBoundarySound_->setSource(OrxoBloxSound);
+        else
+            assert(0); // This should never happen, because soundpointer is only available on master
+    }
+
+    const std::string& OrxoBloxBall::getDefBoundarySound()
+    {
+        if( defBoundarySound_ )
+            return defBoundarySound_->getSource();
+        else
+            assert(0);
+        return BLANKSTRING;
+    }
+}
+
+
Index: /code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/TempData/OrxoBloxBall.h
===================================================================
--- /code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/TempData/OrxoBloxBall.h	(revision 12248)
+++ /code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/TempData/OrxoBloxBall.h	(revision 12248)
@@ -0,0 +1,116 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file OrxoBloxBall.h
+    @brief Declaration of the OrxoBloxBall class.
+    @ingroup OrxoBlox
+*/
+
+#ifndef _OrxoBloxBall_H__
+#define _OrxoBloxBall_H__
+
+#include "OrxoBlox/OrxoBloxPrereqs.h"
+
+#include "util/Math.h"
+
+#include "worldentities/MovableEntity.h"
+
+
+namespace orxonox
+{
+
+    /**
+    @brief
+        This class manages the ball for @ref orxonox::OrxoBlox "OrxoBlox".
+
+        It is responsible for both the movement of the ball in the x,y-plane as well as its interaction with the boundaries of the playing field (defined by the @ref orxonox::OrxoBloxCenterpoint "OrxoBloxCenterpoint") and the @ref orxonox::OrxoBloxBlocks "OrxoBloxBlocks". Or more precisely, it makes the ball bounce off then left and right delimiters of the playing field, it makes the ball bounce off the blocks, damages them and also detects when it reaches the lower bound and takes appropriate measures.
+
+    @author
+        Fabian 'x3n' Landau
+
+    @ingroup OrxoBlox
+    */
+    class _OrxoBloxExport OrxoBloxBall : public MovableEntity
+    {
+        public:
+            OrxoBloxBall(Context* context);
+            virtual ~OrxoBloxBall();
+
+            virtual void tick(float dt) override;
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+
+            /**
+            @brief Set the dimensions of the playing field.
+            @param width The width of the playing field.
+            @param height The height of the playing field.
+            */
+            void setFieldDimension(float width, float height)
+                { this->fieldWidth_ = width; this->fieldHeight_ = height; }
+            /**
+            @brief Get the dimensions of the playing field.
+            @param dimension A vector with the width as the first and height as the second 		    component.
+            */
+            void setFieldDimension(const Vector2& dimension)
+                { this->setFieldDimension(dimension.x, dimension.y); }
+            /**
+            @brief Get the dimensions of the playing field.
+            @return Returns a vector with the width as the first and height as the second 	  	      component.
+            */
+            Vector2 getFieldDimension() const
+                { return Vector2(this->fieldWidth_, this->fieldHeight_); }
+
+            void setSpeed(float speed); //!< Set the speed of the ball (in x-direction).
+            /**
+            @brief Get the speed of the ball (in x-direction).
+            @return Returns the speed of the ball (in x-direction).
+            */
+            float getSpeed() const
+                { return this->speed_; }
+
+            void setBlock(OrxoBloxStone[] blocks, int n); //!< Set the blocks for the ball.
+
+            static const float MAX_REL_Z_VELOCITY;
+
+            void setDefBoundarySound(const std::string& engineSound);
+            const std::string& getDefBoundarySound();
+
+        private:
+            void registerVariables();
+
+            float fieldWidth_; //!< The width of the playing field.
+            float fieldHeight_; //!< The height of the playing field.
+            float speed_; //!< The speed (in x-direction) of the ball.
+            WorldSound* defBoundarySound_;
+            unsigned int nblocks_ ;
+            OrxoBloxStone[] blocks_ ;
+    };
+}
+
+#endif /* _OrxoBloxBall_H__ */
