 void assignDirection(uint8_t a, uint8_t b, uint8_t c, uint8_t d, uint8_t e, uint8_t f, uint8_t g, uint8_t h) {
   movementVal = 0;
   lastDirection = direct;
-  lastBodX = bodX;
-  lastBodY = bodY;
-   if (lastDirection == a) {direct = b;}
+  lastballX = ballX;
+  lastballY = ballY;
+  if (lastDirection == a) {direct = b;}
   else if (lastDirection == c) {direct = d;}
   else if (lastDirection == e) {direct = f;}
   else if (lastDirection == g) {direct = h;}

uint8_t movementVal;
uint16_t scoreR;
uint16_t scoreL;
uint8_t bodX;
uint8_t bodY;
uint8_t lastBodX = 64;
uint8_t lastBodY = 32;
uint8_t direct = START;
uint8_t lastDirection;
uint8_t rndDirection;


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

void checkCollision() {
  if ( ((ballY >= paddleR) && (ballY <= paddleR + 2)) && (ballX >= PADDLE_XR)) { //Right Paddle TOP
    assignDirection(UP_RIGHT, UP_LEFT, UP_RIGHTS, UP_LEFT, DOWN_RIGHT, DOWN_LEFT, DOWN_RIGHTS, DOWN_LEFT);
  } else if ( ((ballY >= paddleR + 3) && (ballY <= paddleR + 3)) && (ballX >= 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 ( ((ballY >= paddleR + 4) && (ballY <= paddleR + 5)) && (ballX >= PADDLE_XR)) { //Right Paddle BOTTOM
    assignDirection(UP_RIGHT, UP_LEFT, UP_RIGHTS, UP_LEFT, DOWN_RIGHT, DOWN_LEFT, DOWN_RIGHTS, DOWN_LEFT);
  } else if ( ((ballY >= paddleL) && (ballY <= paddleL + 2)) && ((ballX >= PADDLE_XL + 1) && (ballX <= 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 ( ((ballY >= paddleL + 3) && (ballY <= paddleL + 3)) && ((ballX >= PADDLE_XL + 1) && (ballX <= 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 ( ((ballY >= paddleL + 4) && (ballY <= paddleL + 5)) && ((ballX >= PADDLE_XL + 1) && (ballX <= 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 (ballX >= 128) { //Right wall
    rndDirection = random(2, 6);
    direct = START;
    movementVal = 0;
    lastballX = ballX;
    lastballY = ballY;
    scoreL++;
  } else if (ballX <= 0) { //Left wall
    rndDirection = random(2, 6);
    direct = START;
    movementVal = 0;
    lastballX = ballX;
    lastballY = ballY;
    scoreR++;
  } else if (ballY <= 1) { //Upper wall
    assignDirection(UP_RIGHT, DOWN_RIGHT, UP_LEFT, DOWN_LEFT, UP_RIGHTS, DOWN_RIGHTS, UP_LEFTS, DOWN_LEFTS);
  } else if (ballY >= 64) { //Bottom wall
    assignDirection(DOWN_RIGHT, UP_RIGHT, DOWN_LEFT, UP_LEFT, DOWN_RIGHTS, UP_RIGHTS, DOWN_LEFTS, UP_LEFTS);
  }
}
