|
|
@ -7,9 +7,12 @@ public class Paddle extends Rectangle { |
|
|
|
int y1; |
|
|
|
int y2; |
|
|
|
int id; |
|
|
|
int x; |
|
|
|
int yVelocity1; |
|
|
|
int yVelocity2; |
|
|
|
int speed = 10; |
|
|
|
int width; |
|
|
|
int height; |
|
|
|
|
|
|
|
Paddle(int x, int y, int width, int height, int id) { |
|
|
|
//super(x, y, width, height); |
|
|
@ -25,18 +28,29 @@ public class Paddle extends Rectangle { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void pressed(KeyEvent e) { |
|
|
|
public void released(KeyEvent e) { |
|
|
|
if (e.getKeyCode() == KeyEvent.VK_W) { |
|
|
|
setYDirection(0, 1); |
|
|
|
} else if (e.getKeyCode() == KeyEvent.VK_S) { |
|
|
|
setYDirection(0, 1); |
|
|
|
} |
|
|
|
|
|
|
|
if (e.getKeyCode() == KeyEvent.VK_UP) { |
|
|
|
setYDirection(0, 2); |
|
|
|
} else if (e.getKeyCode() == KeyEvent.VK_DOWN) { |
|
|
|
setYDirection(0, 2); |
|
|
|
} |
|
|
|
move(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public void released(KeyEvent e) { |
|
|
|
public void pressed (KeyEvent e) { |
|
|
|
if (e.getKeyCode() == KeyEvent.VK_W) { |
|
|
|
setYDirection(-speed, 1); |
|
|
|
} else if (e.getKeyCode() == KeyEvent.VK_S) { |
|
|
|
setYDirection(speed, 1); |
|
|
|
} |
|
|
|
|
|
|
|
// Check if UP or DOWN key was pressed (for paddle 2) |
|
|
|
if (e.getKeyCode() == KeyEvent.VK_UP) { |
|
|
|
setYDirection(-speed, 2); |
|
|
|
} else if (e.getKeyCode() == KeyEvent.VK_DOWN) { |
|
|
|