Changes number of blocks per level. Granted one undo per level.

This commit is contained in:
t-moe
2016-06-20 01:20:32 +02:00
parent 13c391775f
commit 3aa7195ce8

View File

@@ -15,6 +15,7 @@ public class Game {
// Constants // Constants
static final int numberOfColors = 5; static final int numberOfColors = 5;
static final int linesPerLevel = 40; static final int linesPerLevel = 40;
static final int blocksPerLevel []= {3,4,5};
// Private members // Private members
private int[][] field; private int[][] field;
@@ -336,6 +337,7 @@ public class Game {
linesLeft--; linesLeft--;
if(linesLeft==0) { if(linesLeft==0) {
level++; level++;
numUndos++;
linesLeft=linesPerLevel; linesLeft=linesPerLevel;
} }
@@ -443,8 +445,15 @@ public class Game {
} }
} }
int blocksToAdd = 0;
if(level <= blocksPerLevel.length) {
blocksToAdd = blocksPerLevel[level-1];
} else {
blocksToAdd = blocksPerLevel[blocksPerLevel.length-1];
}
// add n new colors to nextBlocks according to the level number. // add n new colors to nextBlocks according to the level number.
for(int i = 0; i < (level * 3); i++){ for(int i = 0; i < blocksToAdd; i++){
nextBlocks.add(1 + rand.nextInt(numberOfColors)); nextBlocks.add(1 + rand.nextInt(numberOfColors));
} }
} }