Add random shape and type control to GridLevelLoader

This commit is contained in:
Matt Low 2018-11-22 17:34:18 +04:00
parent 44c3311cd9
commit 9e8e00e9af

View File

@ -10,16 +10,24 @@ public class GridLevelLoader implements LevelLoader {
public static final int ROUNDS = 2; public static final int ROUNDS = 2;
private PlayState state; private PlayState state;
private boolean randomShape;
private boolean randomType;
private int playCount = 0; private int playCount = 0;
public GridLevelLoader(PlayState state) { public GridLevelLoader(PlayState state) {
this(state, false, false)
}
public GridLevelLoader(PlayState state, boolean randomShape, boolean randomType) {
this.state = state; this.state = state;
this.randomShape = randomShape;
this.randomType = randomType;
} }
@Override @Override
public Level getNextLevel() { public Level getNextLevel() {
if (playCount++ < ROUNDS) { if (playCount++ < ROUNDS) {
return new Level(new GridLayout(state, COLUMNS, ROWS, POWER_UP_CHANCE, true, true)); return new Level(new GridLayout(state, COLUMNS, ROWS, POWER_UP_CHANCE, randomShape, randomType));
} }
return null; return null;
} }