diff --git a/Meteo_Engine.jar b/Meteo_Engine.jar index da32060..f455f1b 100644 Binary files a/Meteo_Engine.jar and b/Meteo_Engine.jar differ diff --git a/src/sig/Block.java b/src/sig/Block.java index c0f6dc0..c22b409 100644 --- a/src/sig/Block.java +++ b/src/sig/Block.java @@ -1,6 +1,7 @@ package sig; import java.awt.Graphics; +import java.awt.Color; public class Block{ BlockState state; @@ -21,8 +22,12 @@ public class Block{ public String toString() { return "Block [state=" + state + ", x=" + x + ", y=" + y + "]"; } - public void draw(Graphics g, double x, double y, int block_width, int block_height) { - g.setColor(state.getCol()); + public void draw(Graphics g, double x, double y, int block_width, int block_height,int launched) { + if (Meteo.DEBUG_DRAWING==DebugMode.MODE0&&launched<=-1) { + g.setColor(Color.BLACK); + } else { + g.setColor(state.getCol()); + } g.fill3DRect((int)x+this.x*block_width,(int)y-this.y*block_height, block_width, block_height, true); } } \ No newline at end of file diff --git a/src/sig/BlockClump.java b/src/sig/BlockClump.java index fd02e05..2f3099a 100644 --- a/src/sig/BlockClump.java +++ b/src/sig/BlockClump.java @@ -4,6 +4,7 @@ import java.awt.Graphics; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.awt.Color; public class BlockClump { private List blocks; @@ -14,7 +15,7 @@ public class BlockClump { 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.*/ - public BlockClump(List blockList, double x, double y, double startspd, int width) { + public BlockClump(List blockList, double x, double y, double startspd, int width, int launched) { this.blocks = new ArrayList(); this.blocks.addAll(blockList); collisionColumnRanges = new int[width][]; @@ -27,6 +28,7 @@ public class BlockClump { this.x=x; this.y=y; this.yspd=startspd; + this.launched=launched; } public void updateBlockCollision() { //Call this whenever the block structure changes. This will define what the top and bottom positions @@ -44,7 +46,18 @@ 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); + b.draw(g,originX+x*block_width,originY-y,block_width,block_height,launched); + } + } + public void drawClumpOutlines(Graphics g, int originX, int originY, int block_width, int block_height) { + if (Meteo.DEBUG_DRAWING==DebugMode.MODE0) { + g.setColor(new Color(0,255,0,128)); + for (int i=0;i initialBlocks2 = new ArrayList(); for (int x=0;xblocks2.y+(blocks2.collisionColumnRanges[x][0]+1)*block_height) { HandleBlockLand(blocks, x, blocks2.y+(blocks2.collisionColumnRanges[x][0]+1)*block_height); + handleCollision=true; continue outerloop; } } else { if (FUTURE_FALL_POSITION+blocks.collisionColumnRanges[x][0]*block_height0) { - blocks.yspd=Math.max(blocks.yspd+gravity,max_fall_spd); - blocks.y+=blocks.yspd; - } else { - //We have hit the bottom. - blocks.yspd=0; - blocks.y=0; + if (!handleCollision) { + if (FUTURE_FALL_POSITION>0) { + blocks.yspd=Math.max(blocks.yspd+gravity,max_fall_spd); + blocks.y+=blocks.yspd; + } else { + //We have hit the bottom. + HandleBlockLand(blocks, x, 0); + } } //System.out.println(blocks.y); } @@ -107,7 +111,7 @@ public class Board { private void HandleBlockLand(BlockClump blocks, int x, double yset) { blocks.yspd=0; blocks.y=yset; - if (blocks.launched--==-1) { + if (blocks.launched--==0) { SplitBlockClump(blocks); } } @@ -118,7 +122,7 @@ public class Board { blockClumpAddList.add( new BlockClump( blocks.getBlocks().stream().filter((block)->block.x==column).collect(Collectors.toList()), - 0,blocks.y,blocks.yspd,width) + 0,blocks.y,blocks.yspd,width,blocks.launched) ); } } @@ -134,5 +138,8 @@ public class Board { } g.setColor(Color.BLACK); g.fillRoundRect(DRAW_STARTX, DRAW_STARTY+block_height, DRAW_ENDX-DRAW_STARTX, 3, 3, 1); + for (BlockClump bc : blockData) { + bc.drawClumpOutlines(g,DRAW_STARTX,DRAW_STARTY,block_width,block_height); + } } } diff --git a/src/sig/DebugMode.java b/src/sig/DebugMode.java new file mode 100644 index 0000000..37de187 --- /dev/null +++ b/src/sig/DebugMode.java @@ -0,0 +1,6 @@ +package sig; + +public enum DebugMode { + OFF, + MODE0, //Displays blocks ready for connecting in black and block clumps with green rectangles. +} diff --git a/src/sig/Meteo.java b/src/sig/Meteo.java index a505a0d..36fa7dd 100644 --- a/src/sig/Meteo.java +++ b/src/sig/Meteo.java @@ -15,6 +15,7 @@ public class Meteo { public static Board b; public final static long TIMEPERTICK = 16666667l; + public static DebugMode DEBUG_DRAWING = DebugMode.MODE0; public static void runGameLoop() { FRAMECOUNT++;