Block launching enabled.

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
concurrentModificationException1
Nic0Nic0Nii 3 years ago
parent 4298dfceb2
commit a0d3bb3135
  1. BIN
      Meteo_Engine.jar
  2. 2
      src/sig/Block.java
  3. 24
      src/sig/Board.java
  4. 4
      src/sig/Meteo.java

Binary file not shown.

@ -16,7 +16,7 @@ public class Block{
public Block(int x,int y) {
this.x=x;
this.y=y;
state = STARTINGSTATES[(int)(Meteo.r.nextInt(1))];
state = STARTINGSTATES[(int)(Meteo.r.nextInt(3))];
}
@Override
public String toString() {

@ -19,6 +19,13 @@ public class Board {
int x,y;
int block_width,block_height;
double vspeed;
final static BlockState[] STARTINGSTATES = {BlockState.BLUE,
BlockState.GREEN,
BlockState.ORANGE,
BlockState.PURPLE,
BlockState.RED,
BlockState.WHITE,
BlockState.YELLOW,};
List<BlockClump> blockClumpDeleteList = new ArrayList<BlockClump>();
List<BlockClump> blockClumpAddList = new ArrayList<BlockClump>();
@ -127,7 +134,7 @@ public class Board {
//System.out.println(blocks.getSortedBlocksOnRow(y));
//System.out.println(blocks.getSortedBlocksOnRow(y));
List<Block> blockList = blocks.getSortedBlocksOnRow(y);
System.out.println(" "+blockList);
//System.out.println(" "+blockList);
markedBlocks.addAll(FindMatches(blockList));
}
for (int x=0;x<width;x++) {
@ -135,17 +142,25 @@ public class Board {
markedBlocks.addAll(FindMatches(blockList));
}
if (markedBlocks.size()>0) {
int minY=Integer.MAX_VALUE;
List<Block> newClumpBlocks = new ArrayList<Block>();
newClumpBlocks.addAll(markedBlocks);
for (Block b : markedBlocks) {
b.state = BlockState.IGNITED;
//All blocks above marked blocks now join the clump.
newClumpBlocks.addAll(blocks.getSortedBlocksOnCol(b.x).stream().filter((block)->!newClumpBlocks.contains(block)&&block.y>b.y).collect(Collectors.toList()));
minY=Math.min(minY,b.y);
}
//For now just get rid of them.
blocks.removeBlock(newClumpBlocks.toArray(new Block[newClumpBlocks.size()]));
for (Block b : newClumpBlocks) {
b.y-=minY;
}
blockClumpAddList.add(
new BlockClump(newClumpBlocks, blocks.x, blocks.y+minY*block_height, launch_power, width, 120)
);
}
return false;
return markedBlocks.size()>0;
}
private List<Block> FindMatches(List<Block> blockList) {
List<Block> markedBlocks = new ArrayList<Block>();
@ -201,6 +216,11 @@ public class Board {
blocks.launched--;
} else
if (blocks.launched==0) {
for (Block b : blocks.getBlocks()) {
if (b.state==BlockState.IGNITED) {
b.state=STARTINGSTATES[(int)(Meteo.r.nextInt(3))];
}
}
SplitBlockClump(blocks);
}
}

@ -1,7 +1,5 @@
package sig;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import javax.swing.JFrame;
@ -27,7 +25,7 @@ public class Meteo {
public static void main(String[] args) {
r = new Random(437210983125739812l);
double[] val = {0,0,};
b = new Board(SCREEN_WIDTH/2,SCREEN_HEIGHT/2,24,24,8,14,-0.065,1,4,-2,val);
b = new Board(SCREEN_WIDTH/2,SCREEN_HEIGHT/2,24,24,8,14,-0.065,5,4,-2,val);
JFrame f = new JFrame("Meteo Engine");
Panel p = new Panel();

Loading…
Cancel
Save