 #define PADDLE_LMID 8
 
 #define SPD0 0
-#define SPD1 48
+#define SPD1 40
 
 #define PADDLE_XL 0
 #define PADDLE_XR 126


void movement(uint8_t i, uint8_t num) {
  if (direct == START) {
    lastBodX = 64;
    lastBodY = 32;
  }
  if (i == UP_RIGHT) {
    bodX = lastBodX + map(movementVal, SPD0, SPD1, 0, 128);
    bodY = lastBodY - map(movementVal, SPD0, SPD1, 0, num);
  } else if (i == UP_LEFT) {
    bodX = lastBodX - map(movementVal, SPD0, SPD1, 0, 128);
    bodY = lastBodY - map(movementVal, SPD0, SPD1, 0, num);
  } else if (i == DOWN_RIGHT) {
    bodX = lastBodX + map(movementVal, SPD0, SPD1, 0, 128);
    bodY = lastBodY + map(movementVal, SPD0, SPD1, 0, num);
  } else if (i == DOWN_LEFT) {
    bodX = lastBodX - map(movementVal, SPD0, SPD1, 0, 128);
    bodY = lastBodY + map(movementVal, SPD0, SPD1, 0, num);
  }
  u8g.drawPixel(bodX, bodY);
  checkCollision();
}

void checkCollision() {
  if ( ((bodY >= paddleR) && (bodY <= paddleR + 2)) && (bodX >= PADDLE_XR)) { //Right Paddle TOP
    assignDirection(UP_RIGHT, UP_LEFT, UP_RIGHTS, UP_LEFT, DOWN_RIGHT, DOWN_LEFT, DOWN_RIGHTS, DOWN_LEFT);
  } else if ( ((bodY >= paddleR + 3) && (bodY <= paddleR + 3)) && (bodX >= PADDLE_XR)) { //Right Paddle TOP-MIDDLE
    assignDirection(UP_RIGHT, UP_LEFTS, UP_RIGHTS, UP_LEFTS, DOWN_RIGHT, DOWN_LEFTS, DOWN_RIGHTS, DOWN_LEFTS);
  } else if ( ((bodY >= paddleR + 4) && (bodY <= paddleR + 5)) && (bodX >= PADDLE_XR)) { //Right Paddle BOTTOM
    assignDirection(UP_RIGHT, UP_LEFT, UP_RIGHTS, UP_LEFT, DOWN_RIGHT, DOWN_LEFT, DOWN_RIGHTS, DOWN_LEFT);
  } else if ( ((bodY >= paddleL) && (bodY <= paddleL + 2)) && ((bodX >= PADDLE_XL + 1) && (bodX <= PADDLE_XL + 3)) ) { //Left Paddle TOP
    assignDirection(UP_LEFT, UP_RIGHT, UP_LEFTS, UP_RIGHT, DOWN_LEFT, DOWN_RIGHT, DOWN_LEFTS, DOWN_RIGHT);
  } else if ( ((bodY >= paddleL + 3) && (bodY <= paddleL + 3)) && ((bodX >= PADDLE_XL + 1) && (bodX <= PADDLE_XL + 3)) ) { //Left Paddle TOP-MIDDLE
    assignDirection(UP_LEFT, UP_RIGHTS, UP_LEFTS, UP_RIGHTS, DOWN_LEFT, DOWN_RIGHTS, DOWN_LEFTS, DOWN_RIGHTS);
  } else if ( ((bodY >= paddleL + 4) && (bodY <= paddleL + 5)) && ((bodX >= PADDLE_XL + 1) && (bodX <= PADDLE_XL + 3)) ) { //Left Paddle BOTTOM
    assignDirection(UP_LEFT, UP_RIGHT, UP_LEFTS, UP_RIGHT, DOWN_LEFT, DOWN_RIGHT, DOWN_LEFTS, DOWN_RIGHT);
  } else if (bodX >= 128) { //Right wall
    rndDirection = random(2, 6);
    direct = START;
    movementVal = 0;
    lastBodX = bodX;
    lastBodY = bodY;
    scoreL++;
  } else if (bodX <= 0) { //Left wall
    rndDirection = random(2, 6);
    direct = START;
    movementVal = 0;
    lastBodX = bodX;
    lastBodY = bodY;
    scoreR++;
  } else if (bodY <= 0) { //Upper wall
    bodY = 0;
    assignDirection(UP_RIGHT, DOWN_RIGHT, UP_LEFT, DOWN_LEFT, UP_RIGHTS, DOWN_RIGHTS, UP_LEFTS, DOWN_LEFTS);
  } else if (bodY >= 64) { //Bottom wall
    bodY = 64;
    assignDirection(DOWN_RIGHT, UP_RIGHT, DOWN_LEFT, UP_LEFT, DOWN_RIGHTS, UP_RIGHTS, DOWN_LEFTS, UP_LEFTS);
  }
}

uint8_t movementVal;
uint16_t scoreR;
uint16_t scoreL;
uint8_t ballX;
uint8_t ballY;
uint8_t lastballX = 64;
uint8_t lastballY = 32;
uint8_t direct = START;
uint8_t lastDirection;
uint8_t rndDirection;
