 /* Moves platform right or left according to pressed keys */
 void movePlatform(void)
 {
-    if (engine.pressed( BUTTON_LEFT ) && (gameState.battleField.platform.p1.x > gameArea.p1.x))
+    if (engine.pressed( BUTTON_LEFT ) && (gameState.battleField.platform.p1.x > 0))
     {
         engine.refreshWorld( gameState.battleField.platform );
         gameState.battleField.platform.move(-1, 0);
         engine.refreshWorld( gameState.battleField.platform );
     }
-    if (engine.pressed( BUTTON_RIGHT ) && (gameState.battleField.platform.p2.x < gameArea.p2.x))
+    if (engine.pressed( BUTTON_RIGHT ) && (gameState.battleField.platform.p2.x < gameArea.width() - 1))
     {
         engine.refreshWorld( gameState.battleField.platform );
         gameState.battleField.platform.move(+1, 0);

    do
    {
        gameState.battleField.ballScaled += gameState.battleField.ballSpeed;
        moveBall = false;
        gameState.battleField.ball = gameState.battleField.ballScaled >> PIX_BITS;
        if (checkGameAreaHit())
        {
            moveBall = true;

bool checkGameAreaHit(void)
{
    bool hit = false;
    if ((gameState.battleField.ball.x < 0) ||
        (gameState.battleField.ball.x >= gameArea.width()))
    {
        hit = true;
        gameState.battleField.ballSpeed.x = -gameState.battleField.ballSpeed.x;
    }
    if ((gameState.battleField.ball.y < 0) ||
        (gameState.battleField.ball.y >= gameArea.height()))
    {
        hit = true;
        gameState.battleField.ballSpeed.y = -gameState.battleField.ballSpeed.y;
        if (gameState.battleField.ball.y >= gameArea.height())
        {
             startBattleField( false );
        }
