Timer changed from control to model

This commit is contained in:
Remco
2015-05-22 12:15:16 +02:00
parent 09caaad7e1
commit 0af599077e
10 changed files with 236 additions and 16 deletions
+32
View File
@@ -0,0 +1,32 @@
package control;
import java.util.ArrayList;
import java.util.List;
import model.gameState.GameState;
import model.gameState.MenuState;
import model.gameState.PlayState;
public class GameStateManager {
private List<GameState> gamestates;
public GameState currentState;
private int index = 0;
public GameStateManager(){
gamestates = new ArrayList<GameState>();
gamestates.add(new MenuState(this));
gamestates.add(new PlayState(this));
currentState = gamestates.get(0);
}
public void next() {
index++;
index %= gamestates.size();
}
public void update(){
currentState = gamestates.get(index);
currentState.update();
}
}