Add in ignition of horizontal matching blocks.
This commit is contained in:
parent
6ed1928bf3
commit
985a71015a
BIN
Meteo_Engine.jar
BIN
Meteo_Engine.jar
Binary file not shown.
@ -47,6 +47,12 @@ public class BlockClump {
|
|||||||
this.blocks.add(b);
|
this.blocks.add(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void removeBlock(Block...blocks) {
|
||||||
|
for (Block b : blocks) {
|
||||||
|
updateBlockCollision();
|
||||||
|
this.blocks.remove(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
public void drawBlocks(Graphics g, int originX, int originY, int block_width, int block_height) {
|
public void drawBlocks(Graphics g, int originX, int originY, int block_width, int block_height) {
|
||||||
for (Block b : blocks) {
|
for (Block b : blocks) {
|
||||||
b.draw(g,originX+x,originY-y,block_width,block_height,launched);
|
b.draw(g,originX+x,originY-y,block_width,block_height,launched);
|
||||||
|
@ -126,8 +126,20 @@ public class Board {
|
|||||||
//System.out.println(blocks.getSortedBlocksOnRow(y));
|
//System.out.println(blocks.getSortedBlocksOnRow(y));
|
||||||
List<Block> blockList = blocks.getSortedBlocksOnRow(y);
|
List<Block> blockList = blocks.getSortedBlocksOnRow(y);
|
||||||
List<Block> markedBlocks = FindMatches(blockList,width,true);
|
List<Block> markedBlocks = FindMatches(blockList,width,true);
|
||||||
|
int ourY = 0;
|
||||||
if (markedBlocks.size()>0) { //Ignite these blocks.
|
if (markedBlocks.size()>0) { //Ignite these blocks.
|
||||||
System.out.println("Marked: "+markedBlocks);
|
//Get all blocks above us. We will be taking all of these out of the current block clump and making a new one.
|
||||||
|
List<Block> newClumpList = new ArrayList<Block>();
|
||||||
|
for (Block b : markedBlocks) { //Get all blocks above this set.
|
||||||
|
newClumpList.addAll(blocks.getBlocks().stream().filter((block)->block.x==b.x&&block.y>b.y).collect(Collectors.toList()));
|
||||||
|
b.state = BlockState.IGNITED;
|
||||||
|
ourY=b.y;
|
||||||
|
}
|
||||||
|
newClumpList.addAll(markedBlocks);
|
||||||
|
BlockClump newClump = new BlockClump(newClumpList,0,blocks.y+ourY*block_height,launch_power,width,120);
|
||||||
|
blocks.removeBlock(markedBlocks.toArray(new Block[markedBlocks.size()]));
|
||||||
|
blockClumpAddList.add(newClump);
|
||||||
|
//System.out.println("Marked: "+markedBlocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int x=0;x<width;x++) {
|
for (int x=0;x<width;x++) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user