Browse Source

refactoring:

main
fdai4616 2 years ago
parent
commit
a5e187c4be
  1. 7
      src/main/java/PingPong/Ball.java
  2. BIN
      target/classes/PingPong/Ball.class

7
src/main/java/PingPong/Ball.java

@ -16,13 +16,18 @@ Random random;
int randomXDirection = random.nextInt(2); int randomXDirection = random.nextInt(2);
if (randomXDirection == 0) if (randomXDirection == 0)
randomXDirection--; randomXDirection--;
setXDirection(randomXDirection * ballSpeed);
xDirect(randomXDirection);
int randomYDirection = random.nextInt(2); int randomYDirection = random.nextInt(2);
if (randomYDirection == 0) if (randomYDirection == 0)
randomYDirection--; randomYDirection--;
setYDirection(randomYDirection * ballSpeed); setYDirection(randomYDirection * ballSpeed);
} }
private void xDirect(int randomXDirection) {
setXDirection(randomXDirection * ballSpeed);
}
public void setXDirection (int randomXDirection){ public void setXDirection (int randomXDirection){
xVelocity = randomXDirection; xVelocity = randomXDirection;
} }

BIN
target/classes/PingPong/Ball.class

Loading…
Cancel
Save