"Stuttering" in windowed mode using Java2D

Double and Float are floating point primitive types. Float is a shorter Double, by exactly half.
Double is more recommended here.

Ah, sorry I completely misread your post there. I’m definitely now using doubles haha.

Although I’m confused now ra4king - when I implemented a FPS counter, (tried it in several different ways) it always gave the correct FPS (to what I had set it to) - yet there would still be stuttering now and again.

If it isn’t the gameloop then (as the FPS is reported as being 60)… what else could it be? (Or was your comment on the fact that the FPS could have possibly be being reported incorrectly).

Using an external timer seems to be working better really at the moment (unless my eyes have just stopped being fussy and are starting to ignore the slight stutter lol).

Are you using the same thread for updating and drawing or are you relying on repaint() (EDT)?

Using the same thread for drawing and with a buffer (BufferStrategy… then drawing to buffer… then showing buffer etc).

Haha accidentally clicked “Appreciate”. Well free medal for you :stuck_out_tongue:

Well if the FPS stays constant and the drawing is done in the game loop, then I don’t know how it would stutter other than being a bug in your game code.

I don’t know if it will help, but you could try looking more closely at exactly how constant your frame-rate is. (To be honest, I’m a little suspicious when you say the counter always gives you the “correct FPS”. You mean it always says 60, never 59.9 or 60.1? What period are you averaging the FPS over?)

For 60 frames-per-second, the value of nanoTime() at the start of the current loop minus the value at the start of the previous loop would ideally be around 1e9/60 (=16,666,666). Try printing out the value if it is significantly different from that (for instance, less than 5,000,000 or more than 30,000,000). Do you see these numbers do anything strange when the game stutters? What are the most extreme numbers that are printed?

Simon

Are you using delta-timing? If not, then an FPS change can make the game stutter a bit. :point: