Include maxheight check and debug output

concurrentModificationException1
sigonasr2, Sig, Sigo 3 years ago
parent d41e25cb8e
commit 1d9d01efc1
  1. BIN
      Meteo_Engine.jar
  2. 15
      src/sig/BlockClump.java
  3. 9
      src/sig/Board.java
  4. 1
      src/sig/DebugMode.java
  5. 2
      src/sig/Meteo.java

Binary file not shown.

@ -11,8 +11,9 @@ public class BlockClump {
double x,y; //the lower-left origin of this block clump. Every block positions relative to this.
double yspd;
int[][] collisionColumnRanges;
int maxBlockHeight=0; //Gives the height in blocks. So if the top is 0, this should be 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. 0=Ready for split. -1=Ready for merging. -2=Merged (Dead clump)
Positive is used for how much landing launch time before being split and falling.*/
public BlockClump(List<Block> blockList, double x, double y, double startspd, int width, int launched) {
@ -32,6 +33,7 @@ public class BlockClump {
//Call this whenever the block structure changes. This will define what the top and bottom positions
//of each vertical column are for faster collision checking.
collisionColumnRanges = new int[collisionColumnRanges.length][];
maxBlockHeight=0;
for (int i=0;i<collisionColumnRanges.length;i++) {
collisionColumnRanges[i] = new int[]{-1,-1};
@ -47,11 +49,15 @@ public class BlockClump {
}
public void drawBlocks(Graphics g, int originX, int originY, int block_width, int block_height) {
for (Block b : blocks) {
b.draw(g,originX+x*block_width,originY-y,block_width,block_height,launched);
b.draw(g,originX+x,originY-y,block_width,block_height,launched);
if (Meteo.DEBUG_DRAWING==DebugMode.MODE2) {
g.setColor(Color.BLACK);
g.drawString(Integer.toString(maxBlockHeight),(int)x+b.x*block_width+originX+4,(int)-y-b.y*block_height+originY+16);
}
}
}
public void drawClumpOutlines(Graphics g, int originX, int originY, int block_width, int block_height) {
if (Meteo.DEBUG_DRAWING==DebugMode.MODE0||Meteo.DEBUG_DRAWING==DebugMode.MODE1) {
if (Meteo.DEBUG_DRAWING!=DebugMode.OFF) {
g.setColor(new Color(0,255,0,128));
for (int i=0;i<collisionColumnRanges.length;i++) {
if (collisionColumnRanges[i][0]!=-1) {
@ -62,7 +68,7 @@ public class BlockClump {
}
}
public void drawClumpDots(Graphics g, int originX, int originY, int block_width, int block_height) {
if (Meteo.DEBUG_DRAWING==DebugMode.MODE0||Meteo.DEBUG_DRAWING==DebugMode.MODE1) {
if (Meteo.DEBUG_DRAWING!=DebugMode.OFF) {
g.setColor(Color.RED);
g.drawOval((int)x+originX,(int)-y+originY,2,2);
}
@ -77,6 +83,7 @@ public class BlockClump {
}
if (collisionColumnRanges[b.x][1]==-1||collisionColumnRanges[b.x][1]<b.y) {
collisionColumnRanges[b.x][1]=b.y;
maxBlockHeight=b.y+1;
}
}

@ -65,6 +65,7 @@ public class Board {
outerloop:
for (BlockClump blocks : blockData) {
if (checkForMatches(blocks)) {continue;}
double FUTURE_FALL_POSITION = blocks.y+blocks.yspd+gravity;
for (int x=0;x<width;x++) {
if (blocks.collisionColumnRanges[x][0]!=-1) {
@ -106,6 +107,14 @@ public class Board {
blockData.addAll(blockClumpAddList);
blockClumpAddList.clear();
}
}
private boolean checkForMatches(BlockClump blocks) {
//Start from one block and work our way across, seeing if we can make a match of 3 or more. Go to the next row, repeat. Then do the columns. Once all blocks marked for ignition, ignite them and send them.
//Lowest block is used as the block clump starting point.
for (int y=0;y<blocks.maxBlockHeight;y++) {
}
return false;
}
private void CombineAToB(BlockClump A, BlockClump B) {
for (Block b : A.getBlocks()) {

@ -4,4 +4,5 @@ public enum DebugMode {
OFF,
MODE0, //Displays blocks ready for connecting in black and block clumps with green rectangles.
MODE1, //Displays block clumps with green rectangles only.
MODE2, //Shows height of clumps.
}

@ -15,7 +15,7 @@ public class Meteo {
public static Board b;
public final static long TIMEPERTICK = 16666667l;
public static DebugMode DEBUG_DRAWING = DebugMode.MODE1;
public static DebugMode DEBUG_DRAWING = DebugMode.MODE2;
public static void runGameLoop() {
FRAMECOUNT++;

Loading…
Cancel
Save