I built a simple "Ping-Pong" 2D game in Java.
The game uses a Swing timer that goes off every 5 milliseconds and triggers an actionPerformed method.
This method "moves" (every 5 milliseconds) items on the screen, by changing their x and y coordinates and repainting the screen.
About an hour ago, the game ran fine. I then took a break and got back to the computer about a minute ago.
Now, when I run the game, everything is much slower. (For example, the "ping pong ball" the flies around the screen doesn't move as fast as it previously had).
What could be the problem? (I didn't think providing code was necessary, because maybe this kind of problem isn't related to the code, since it didn't change before the problem started to occure. If it is please let me know).
EDIT: Some code:
In the constructor of the main object of the program:
timer = new Timer(40,this);
timer.start();
In the main object's actionPerformed:
public void actionPerformed(ActionEvent e) {
bPaddle.move();
tPaddle.move();
ball.move();
checkCollision();
checkInScreen();
repaint();
}
Anything else from the program to add here?
Thanks.