package sig; import java.awt.Graphics; import java.awt.Color; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; public class Board { List blockData; int width; int height; double gravity; double launch_power; double max_rise_spd; double max_fall_spd; double[] combo_power_bonus; int x,y; int block_width,block_height; double vspeed; List blockClumpDeleteList = new ArrayList(); List blockClumpAddList = new ArrayList(); 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) { this.x=centerX; this.y=centerY; this.block_width=block_width; this.block_height=block_height; this.width = boardWidth; this.height = boardHeight; this.gravity = gravity; this.launch_power = launch_power; this.max_rise_spd = max_rise_spd; this.max_fall_spd = max_fall_spd; this.combo_power_bonus = combo_power_bonus; this.blockData = new ArrayList(); List initialBlocks = new ArrayList(); for (int x=0;x 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); 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. HandleBlockLand(blocks, x, 0); } //System.out.println(blocks.y); } if (blockClumpDeleteList.size()>0) { blockData.removeAll(blockClumpDeleteList); blockClumpDeleteList.clear(); } if (blockClumpAddList.size()>0) { 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;y0) { blocks.launched--; } else if (blocks.launched==0) { SplitBlockClump(blocks); } } private void SplitBlockClump(BlockClump blocks) { for (int x=0;xblock.x==column).collect(Collectors.toList()), 0,blocks.y,blocks.yspd,width,blocks.launched-1) ); } } blockClumpDeleteList.add(blocks); } public void drawBoard(Graphics g) { 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_ENDX = (int)(x + block_width*((double)width/2)); for (BlockClump bc : blockData) { bc.drawBlocks(g,DRAW_STARTX,DRAW_STARTY,block_width,block_height); } g.setColor(Color.BLACK); g.fillRoundRect(DRAW_STARTX, DRAW_STARTY+block_height, DRAW_ENDX-DRAW_STARTX, 3, 3, 1); BlockClump.drawDebugBlockClumps(g,DRAW_STARTX,DRAW_STARTY,block_width,block_height,blockData); } }