So basically I try to get back into Java by programming a round based Game
Till now you only could start a new round by pressing a button ( x)
if (x.getKeyChar() == 'o') {
TimerRounds.cancel();
// methods to start the next round //
TimerRounds = new Timer();
// Timer Method
Timer Rounds.schedule(new TimerTask() {
public void run() {
System.out.println("Time is over, next round is started");
//methods to start the next round //
//Timer has to start from the beginning again//
//already tried to start the timer here, didnĀ“t work//
}
}, 3000);
Let me explain the code: If the player presses o, a new round is started and it is t he turn of the next player. However, in addition to that, there is a countdown for each round and if the countdown is expired, a new round starts automatically
I manage to do everything, but what I do not understand is the following problem: The Timer ends and a new round starts , but how do I manage that it automatically starts a new timer for the next round? Till now it only does when the key is pressed, but I want it to start a new timer as well whenever the countdown from the last round is expired.
I hope you get the Problem, my english is really bad Would be great to get some advice