Original Post
I am new to Java (and OOP in general) and have recently been trying my hand at programming some basic games. My first two attempts used a Timer, with an ActionListener to call for game updates, which seemed to work pretty smoothly (granted these games only used a text interface.) In preparing for my most recent game (a breakout clone) I noticed another user on the forum using a sleep() inside a game thread. My initial observations of this in both his game, and in my own when I implemented it, was that the speed didn't feel constant, like the game would randomly speed up and slow down, presumably on processor load. Is this just a problem with implementation? Which is the preferred method, Timers, or threads? If it is threads, which my gut feel seems to be, how would you avoid this problem? Should the game thread that updates movement etc be a separate thread than the one that calls for screen refreshes?
Thank you for the guidance.
Thank you for the guidance.