|
|
@ -9,6 +9,7 @@ public class Paddle extends Rectangle { |
|
|
|
int id; |
|
|
|
int yVelocity1; |
|
|
|
int yVelocity2; |
|
|
|
int speed = 1; |
|
|
|
|
|
|
|
Paddle(int x, int y, int width, int height, int id) { |
|
|
|
//super(x, y, width, height); |
|
|
@ -29,6 +30,19 @@ public class Paddle extends Rectangle { |
|
|
|
} |
|
|
|
|
|
|
|
public void released(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) { |
|
|
|
setYDirection(speed, 2); |
|
|
|
} |
|
|
|
move(); |
|
|
|
} |
|
|
|
|
|
|
|
public void move() { |
|
|
|