You are on page 1of 2

package pongs;

import java.awt.Color;
import java.awt.Graphics;
public class HumanPaddle implements Paddle{
double y, yVel;
boolean upAccel, downAccel;
int player, x;
final double FRICTION = 0.9;
public HumanPaddle(int player){
upAccel = false;
downAccel = false;
y = 210; yVel = 0;
if (player == 1)
x = 0;
else
x = 1220;
}
public void draw(Graphics g) {
g.setColor(Color.white);
g.fillRect(x + 20, (int)y, 20, 150);
}
public void move() {
if(upAccel){
yVel -= 2;
}
else if(downAccel){
yVel += 2;
}
else if(!upAccel && !downAccel){
yVel *= FRICTION;
}
y += yVel;
if (yVel >= 7)
yVel = 7;
else if (yVel <= -7)
yVel = -7;
if (y < 0)
y = 0;
if (y > 570)
y = 570;
}
public void setUpAccel (boolean input){
upAccel = input;
}
public void setDownAccel (boolean input){
downAccel = input;
}
public int getY() {
return (int)y;

}
public double getYVel(){
return (double) yVel;
}
}

You might also like