I'm making a game with Java and I'm currently using Timers for all my animations and game controls. But I'm having trouble choosing the right way to increase the speed of a Timer. My game is supposed to get faster and faster as the game progresses, and I'm finding that there are many ways to increase the speed of my objects, but I'm not sure which one is the most efficient to use.
For example, let's say the int
xpos is the variable the increments the xposition of an object.
Timer timer = new Timer(100, new ActionListener() //01
public void actionPerformed(ActionEvent e) //03
To increase the speed of this, I could increase the incrementation of xpos on line 5 to
I could also increase the speed by decreasing the millisecond parameter for the Timer to:
Timer timer = new Timer(50, new ActionListener() on line 1.
Or I could add a second Timer that would do the same task to double the speed of the timer. Basically, I could do this:
Mover mover = new Mover();
Timer timer = new Timer(100, mover);
Timer timer2 = new Timer(100, mover);
class Mover implements ActionListener
public void actionPerformed(ActionEvent e)
Which one do you think would be most effective? Or should I combine all these techniques? Thanks for any replies.