 |
Accurate Timing
Up until and include Java 1.4.2 the only way of determining the system time is System.currentTimeMillis(). Unfortunately on some Windows operating system the underlying implementation of the method is only accurate to around 16ms. This results incorrect timing and often ends up with inconsistent frame rates in games.
There are several ways round this:
Java 1.5
Java 1.5 introduces the new nanoTime() method which gives sub-millisecond accuracy. This is the "right" solution, however since most users who have Java don't have 1.5 (yet?) this isn't always desirable.
GAGETimer
The GAGE library provides a timer package that gives accurate timing on Windows platforms via a native library (see NativeBindings). It abstracts the timing mechanism under a layer that means on Java 1.5 it will use nanoTime(), on non-windows platforms it will use currentTimeMillis() and where required it'll use the native. Great library!
LWJGL has an accurate timer provided by its native libraries. This gives the time in "ticks" and a resolution to convert between ticks and milliseconds.
-- Main.kevglass - 24 Oct 2005
|