Hi! I’m trying to do smooth (not choppy) animation, but all the timers I tried (Timer.sleep, LockSupport.parkNanos) have too much jitter, or maybe something else, but the animation simply isn’t smooth. I’m using bufferstrategy and have 300-400 fps without FPS limit.
The only good timing is this (nearly busy wait, because it has high cpu load):
while( System.nanoTime()-timeout < (1000.0/60.0)*1000000)
Thread.yield();
I even tryied wait for 10ms and then busy wait, but this is also choppy.
I want the game to be playable from web page (applet), so I want to use only pure java (java2d) because of security dialogs. Is there a good solution which doesn’t load cpu?