Split block clumps into vertical sections after launch delay expires.

concurrentModificationException1
Joshua Sigona 3 years ago
parent af8c5ce854
commit dbb8a0f88d
  1. BIN
      Meteo_Engine.jar
  2. 7
      src/sig/BlockClump.java
  3. 33
      src/sig/Board.java
  4. 5
      src/sig/Meteo.java

Binary file not shown.

@ -10,7 +10,7 @@ public class BlockClump {
double x,y; //the lower-left origin of this block clump. Every block positions relative to this. double x,y; //the lower-left origin of this block clump. Every block positions relative to this.
double yspd; double yspd;
int[][] collisionColumnRanges; int[][] collisionColumnRanges;
int launched = -1; /* int launched = 120; /*
Negative is for when block clumps are divided into smaller columns for re-sorting. Negative is for when block clumps are divided into smaller columns for re-sorting.
Positive is used for how much landing launch time before being split and falling.*/ Positive is used for how much landing launch time before being split and falling.*/
@ -48,7 +48,10 @@ public class BlockClump {
} }
} }
private void updateBlockCollisionRangeWithBlock(Block b) { public List<Block> getBlocks() {
return blocks;
}
private void updateBlockCollisionRangeWithBlock(Block b) {
if (collisionColumnRanges[b.x][0]==-1||collisionColumnRanges[b.x][0]>b.y) { if (collisionColumnRanges[b.x][0]==-1||collisionColumnRanges[b.x][0]>b.y) {
collisionColumnRanges[b.x][0]=b.y; collisionColumnRanges[b.x][0]=b.y;
} }

@ -5,6 +5,7 @@ import java.awt.Color;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
public class Board { public class Board {
List<BlockClump> blockData; List<BlockClump> blockData;
@ -18,6 +19,10 @@ public class Board {
int x,y; int x,y;
int block_width,block_height; int block_width,block_height;
double vspeed; double vspeed;
List<BlockClump> blockClumpDeleteList = new ArrayList<BlockClump>();
List<BlockClump> blockClumpAddList = new ArrayList<BlockClump>();
public Board(int centerX,int centerY,int block_width,int block_height,int boardWidth, int boardHeight, double gravity, double launch_power, double max_rise_spd, double max_fall_spd, public Board(int centerX,int centerY,int block_width,int block_height,int boardWidth, int boardHeight, double gravity, double launch_power, double max_rise_spd, double max_fall_spd,
double[] combo_power_bonus) { double[] combo_power_bonus) {
this.x=centerX; this.x=centerX;
@ -54,7 +59,6 @@ public class Board {
blockData.add(defaultClump2); blockData.add(defaultClump2);
} }
public void run(long frames) { public void run(long frames) {
if (frames%100==0) { if (frames%100==0) {
blockData.add(new BlockClump(Arrays.asList(new Block((int)(Math.random()*width),0)),0,590,0,width)); blockData.add(new BlockClump(Arrays.asList(new Block((int)(Math.random()*width),0)),0,590,0,width));
} }
@ -91,13 +95,36 @@ public class Board {
} }
//System.out.println(blocks.y); //System.out.println(blocks.y);
} }
if (blockClumpDeleteList.size()>0) {
blockData.removeAll(blockClumpDeleteList);
blockClumpDeleteList.clear();
}
if (blockClumpAddList.size()>0) {
blockData.addAll(blockClumpAddList);
blockClumpAddList.clear();
}
} }
private void HandleBlockLand(BlockClump blocks, int x, double yset) { private void HandleBlockLand(BlockClump blocks, int x, double yset) {
blocks.yspd=0; blocks.yspd=0;
blocks.y=yset; blocks.y=yset;
if (blocks.launched--==-1) {
SplitBlockClump(blocks);
}
}
private void SplitBlockClump(BlockClump blocks) {
for (int x=0;x<width;x++) {
if (blocks.collisionColumnRanges[x][0]!=-1) {
final int column=x;
blockClumpAddList.add(
new BlockClump(
blocks.getBlocks().stream().filter((block)->block.x==column).collect(Collectors.toList()),
0,blocks.y,blocks.yspd,width)
);
}
}
blockClumpDeleteList.add(blocks);
} }
public void drawBoard(Graphics g) { public void drawBoard(Graphics g) {
final int DRAW_STARTX = (int)(x - block_width*((double)width/2)); final int DRAW_STARTX = (int)(x - block_width*((double)width/2));
final int DRAW_STARTY = (int)(y + block_height*((double)height/2)); final int DRAW_STARTY = (int)(y + block_height*((double)height/2));
final int DRAW_ENDX = (int)(x + block_width*((double)width/2)); final int DRAW_ENDX = (int)(x + block_width*((double)width/2));

@ -1,5 +1,8 @@
package sig; package sig;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JFrame; import javax.swing.JFrame;
public class Meteo { public class Meteo {
@ -18,7 +21,7 @@ public class Meteo {
b.run(FRAMECOUNT); b.run(FRAMECOUNT);
} }
public static void main(String[] args) { public static void main(String[] args) {
double[] val = {0,0,}; 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,1,4,-2,val);

Loading…
Cancel
Save