am i asking for too much accuracy or is it reasonable to expect a higher frame rate?
Do the frameworks / engines for java games all fix this problem?
I think you misunderstood the accuracy statement. It did not neccessarily
reference to your performance problems, but to the fact, that you measurement is flawed, since the System.currentTimeMillies() just don't return milliseconds, but "jumps" around in chunks of ~15+ milliseconds depending on your system.
To measure times, the easiest would be to make your game require a JDK > 1.5 and use System.nanoTime()
Regarding your performance problem, it is hard to tell without seeing your actual rendering code. There are a lot of possibilities to cause this "blips": - You are using the inaccurate timer to calculate you ball-movement conclusion:
you don't have a peformance problem at all, just your math is influenced by the
currentTimeMillies shortcumming solution:
use System.nanoTime() or meassure the time over a larger duration (e.g. 10frames)
and divide the result as needed- You are updating your coordinates only in the mouse listener callback conclusion:
the mouse listener is called an an irregular basis, so you migt get to many
or to few events for a smooth animation solution:
try to smooth the mouse-movement by calculating averages for mouse movement
direction and speed based on the mouse listener callbacks and animate you movements in a
constant render loop based on this values- You are repainting the panel inside the mouse listener callbacks conclusion:
depending on your rendering speed, this might block enqueue mouse events,
so you get jumpy time frames between the mouse listener calls. solution:
do the rendering in a dedicated rendering loop by painting on a BufferedImage
and just blit the finished "scene" to the panel in an SwingUtilities.invokeLater() call. The last step
could possibly be circumvented by (in/re)-validate/repaint your panel, but I am not so familiar with
realtime animations in Swing/AWT.
Maybe there are other possible problems, too