Browse Source

update

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

14
src/main/java/PingPong/Paddle.java

@ -3,10 +3,12 @@ package PingPong;
import java.awt.*; import java.awt.*;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
public class Paddle extends Rectangle{
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