So I am trying to make the popular game pong in java. I've made the player rectangle and setup the action listener so I am ready to move the player up and down on the screen. But I have run into a problem. When I am moving the player I have a choice of moving X pixels per move.
But if I set the X pixels being moved to lets say 1. Then the player is moving too slow. If I set X pixels to 10 then he skips 9 pixels and the animation looks rough. How can I smoothen the animation and still move fast?
here is some code:
public void keyPressed(KeyEvent e) {
if(e.getKeyCode() == keyUp){
playerYCordinate -= 10;
}else if(e.getKeyCode() == keyDown){
playerYCordinate += 10;
}
repaint();
}
public void keyReleased(KeyEvent e) {
if(e.getKeyCode() == keyUp){
}else if(e.getKeyCode() == keyDown){
}
repaint();
}