My program that I am making is tetris. One part I got stuck on was decreasing the speed in the timer when the player reaches a certain score. For instance, every 200 points (modulo will check) will decrease the time lets say by 50. Initially the time started at 500 ms. I can't seen to figure out how to decrease it because once I created the Timer, the time that is passed in doesn't change.
** My constructor which instantiates the timer.
public PlayingPanel(SidePanel p)
{
pf = new PlayingField(p);
generateNewPiece();
setFocusable(true);
addKeyListener(new KeyEvent());
timer = new Timer(time, new BlockListener());
timer.start();
}
public void startTimer()
{
time -= 20;
}
/**
* generates new piece
*/
public void generateNewPiece()
{
startTimer();
...
}