timer inconsistencies

So, I use javax.swing.timer quite a bit, and I’ve noticed that the time inbetween iterations varies quite a bit. When I start up my IDE, the first time I run it everything goes hella fast. Then, after that, it’s way too slow.

Any way to regulate this?

Note: the inconsistencies aren’t consistent, either. :stuck_out_tongue:

Yes. Don’t use Timer :stuck_out_tongue: it’s horridly inaccurate for gamedev.

ok…
what should I use, then?

Well, what are you using Timer for?

Movement of sprites, other stuff.

So, your using it as your gameloop? Read this

No, not really, I have a timer called moveTimer in my Enemy class (separate from my gameloop)
I’m too good with class architecture and whatnot, never took any lessons ;D
I’ll move it to the gameloop, then

Normally game loops consist of getting input, updating, and rendering. For my games I get input, then I update all the sprites and the user (which usually consists of moving them), and then I render. I don’t know how your Enemy (or your game) works so I don’t know if that applies to you or not. Timer just isn’t very accurate, as you’ve noticed.

wouldn’t you want to update first? So then the rendering properly represents where everything is? I know people probably could not tell the difference but I am just wondering if there is some other reason.

Whoops, your right. My mistake x)