Browse Source

update

main
fdai4616 2 years ago
parent
commit
3ecee36fd2
  1. 12
      src/main/java/PingPong/Paddle.java

12
src/main/java/PingPong/Paddle.java

@ -7,6 +7,8 @@ public class Paddle extends Rectangle{
int y1; int y1;
int y2; int y2;
int id; int id;
int yVelocity1;
int yVelocity2;
Paddle(int x, int y, int width, int height, int id) { Paddle(int x, int y, int width, int height, int id) {
//super(x, y, width, height); //super(x, y, width, height);
@ -20,7 +22,9 @@ public class Paddle extends Rectangle{
this.height = height; this.height = height;
this.id = id; this.id = id;
} }
public void pressed(KeyEvent e) { public void pressed(KeyEvent e) {
} }
public void released(KeyEvent e) { public void released(KeyEvent e) {
@ -28,4 +32,12 @@ public class Paddle extends Rectangle{
public void move() { public void move() {
} }
public void setYDirection(int yDirection, int paddleId) {
if (paddleId == 1) {
yVelocity1 = yDirection;
} else if (paddleId == 2) {
yVelocity2 = yDirection;
}
}
} }
Loading…
Cancel
Save