|
|
@ -38,9 +38,9 @@ public class Board { |
|
|
|
this.combo_power_bonus = combo_power_bonus; |
|
|
|
this.combo_power_bonus = combo_power_bonus; |
|
|
|
this.blockData = new ArrayList<BlockClump>(); |
|
|
|
this.blockData = new ArrayList<BlockClump>(); |
|
|
|
|
|
|
|
|
|
|
|
List<Block> initialBlocks = new ArrayList<Block>(); |
|
|
|
/*List<Block> initialBlocks = new ArrayList<Block>(); |
|
|
|
for (int x=0;x<boardWidth;x++) { |
|
|
|
for (int x=0;x<boardWidth;x++) { |
|
|
|
for (int y=0;y<(int)(Math.random()*12);y++) { |
|
|
|
for (int y=0;y<(int)(Meteo.r.nextInt(12));y++) { |
|
|
|
initialBlocks.add(new Block(x,y)); |
|
|
|
initialBlocks.add(new Block(x,y)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -49,18 +49,18 @@ public class Board { |
|
|
|
|
|
|
|
|
|
|
|
List<Block> initialBlocks2 = new ArrayList<Block>(); |
|
|
|
List<Block> initialBlocks2 = new ArrayList<Block>(); |
|
|
|
for (int x=0;x<boardWidth;x++) { |
|
|
|
for (int x=0;x<boardWidth;x++) { |
|
|
|
for (int y=0;y<(int)(Math.random()*12);y++) { |
|
|
|
for (int y=0;y<(int)(Meteo.r.nextInt(12));y++) { |
|
|
|
initialBlocks2.add(new Block(x,y)); |
|
|
|
initialBlocks2.add(new Block(x,y)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
BlockClump defaultClump2 = new BlockClump(initialBlocks2,0,540,0,width,120); |
|
|
|
BlockClump defaultClump2 = new BlockClump(initialBlocks2,0,540,0,width,120); |
|
|
|
|
|
|
|
|
|
|
|
blockData.add(defaultClump); |
|
|
|
blockData.add(defaultClump); |
|
|
|
blockData.add(defaultClump2); |
|
|
|
blockData.add(defaultClump2);*/ |
|
|
|
} |
|
|
|
} |
|
|
|
public void run(long frames) { |
|
|
|
public void run(long frames) { |
|
|
|
if (frames%40==0) { |
|
|
|
if (frames%20==0) { |
|
|
|
blockData.add(new BlockClump(Arrays.asList(new Block((int)(Math.random()*width),0)),0,590,0,width,-1)); |
|
|
|
blockData.add(new BlockClump(Arrays.asList(new Block((int)(Meteo.r.nextInt(width)),0)),0,590,0,width,-1)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
outerloop: |
|
|
|
outerloop: |
|
|
@ -127,11 +127,12 @@ public class Board { |
|
|
|
//System.out.println(blocks.getSortedBlocksOnRow(y));
|
|
|
|
//System.out.println(blocks.getSortedBlocksOnRow(y));
|
|
|
|
//System.out.println(blocks.getSortedBlocksOnRow(y));
|
|
|
|
//System.out.println(blocks.getSortedBlocksOnRow(y));
|
|
|
|
List<Block> blockList = blocks.getSortedBlocksOnRow(y); |
|
|
|
List<Block> blockList = blocks.getSortedBlocksOnRow(y); |
|
|
|
markedBlocks.addAll(FindMatches(blockList,width,true)); |
|
|
|
System.out.println(" "+blockList); |
|
|
|
|
|
|
|
markedBlocks.addAll(FindMatches(blockList)); |
|
|
|
} |
|
|
|
} |
|
|
|
for (int x=0;x<width;x++) { |
|
|
|
for (int x=0;x<width;x++) { |
|
|
|
List<Block> blockList = blocks.getSortedBlocksOnCol(x); |
|
|
|
List<Block> blockList = blocks.getSortedBlocksOnCol(x); |
|
|
|
markedBlocks.addAll(FindMatches(blockList,blocks.maxBlockHeight,false)); |
|
|
|
markedBlocks.addAll(FindMatches(blockList)); |
|
|
|
} |
|
|
|
} |
|
|
|
if (markedBlocks.size()>0) { |
|
|
|
if (markedBlocks.size()>0) { |
|
|
|
List<Block> newClumpBlocks = new ArrayList<Block>(); |
|
|
|
List<Block> newClumpBlocks = new ArrayList<Block>(); |
|
|
@ -146,22 +147,23 @@ public class Board { |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
private List<Block> FindMatches(List<Block> blockList, int maxSearch, boolean searchingRows) { |
|
|
|
private List<Block> FindMatches(List<Block> blockList) { |
|
|
|
BlockState col = BlockState.IGNITED; |
|
|
|
|
|
|
|
int matches=0; |
|
|
|
|
|
|
|
List<Block> markedBlocks = new ArrayList<Block>(); |
|
|
|
List<Block> markedBlocks = new ArrayList<Block>(); |
|
|
|
List<Block> tempMarkedBlocks = new ArrayList<Block>(); |
|
|
|
List<Block> tempMarkedBlocks = new ArrayList<Block>(); |
|
|
|
for (int i=0;i<maxSearch;i++) { |
|
|
|
if (blockList.size()==0) {return markedBlocks;} |
|
|
|
if (blockList.isEmpty()) {break;} |
|
|
|
BlockState col = blockList.get(0).state; |
|
|
|
|
|
|
|
int matches= 1; |
|
|
|
|
|
|
|
int prevX = blockList.get(0).x; |
|
|
|
|
|
|
|
int prevY = blockList.get(0).y; |
|
|
|
|
|
|
|
while (blockList.size()>0) { |
|
|
|
Block currentBlock = blockList.get(0); |
|
|
|
Block currentBlock = blockList.get(0); |
|
|
|
if (searchingRows&¤tBlock.x==i||(!searchingRows&¤tBlock.y==i)) { |
|
|
|
if (Math.abs(currentBlock.x-prevX)==1||Math.abs(currentBlock.y-prevY)==1) { |
|
|
|
if (col!=BlockState.IGNITED&¤tBlock.state==col) { |
|
|
|
if (col!=BlockState.IGNITED&¤tBlock.state==col) { |
|
|
|
matches++; |
|
|
|
matches++; |
|
|
|
tempMarkedBlocks.add(blockList.remove(0)); |
|
|
|
tempMarkedBlocks.add(blockList.remove(0)); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (matches>=3) { |
|
|
|
if (matches>=3) { |
|
|
|
markedBlocks.addAll(tempMarkedBlocks); |
|
|
|
markedBlocks.addAll(tempMarkedBlocks); |
|
|
|
System.out.println(" Added to Marked blocks: "+tempMarkedBlocks); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
matches=1; |
|
|
|
matches=1; |
|
|
|
col=currentBlock.state; |
|
|
|
col=currentBlock.state; |
|
|
@ -169,14 +171,19 @@ public class Board { |
|
|
|
tempMarkedBlocks.add(blockList.remove(0)); |
|
|
|
tempMarkedBlocks.add(blockList.remove(0)); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
col = BlockState.IGNITED; |
|
|
|
if (matches>=3) { |
|
|
|
matches=0; |
|
|
|
markedBlocks.addAll(tempMarkedBlocks); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
matches=1; |
|
|
|
|
|
|
|
col=currentBlock.state; |
|
|
|
tempMarkedBlocks.clear(); |
|
|
|
tempMarkedBlocks.clear(); |
|
|
|
|
|
|
|
tempMarkedBlocks.add(blockList.remove(0)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
prevX=currentBlock.x; |
|
|
|
|
|
|
|
prevY=currentBlock.y; |
|
|
|
} |
|
|
|
} |
|
|
|
if (matches>=3) { |
|
|
|
if (matches>=3) { |
|
|
|
markedBlocks.addAll(tempMarkedBlocks); |
|
|
|
markedBlocks.addAll(tempMarkedBlocks); |
|
|
|
System.out.println(" Added to Marked blocks: "+tempMarkedBlocks); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return markedBlocks; |
|
|
|
return markedBlocks; |
|
|
|
} |
|
|
|
} |
|
|
|