diff --git a/BlockClump.cpp b/BlockClump.cpp index 843dfe6..a56e20d 100644 --- a/BlockClump.cpp +++ b/BlockClump.cpp @@ -8,7 +8,11 @@ void BlockClump::addBlock(int col){ blocks.push_back(Block({(float)col*12,0})); } -void BlockClump::addBlock(vi2d offset){ +void BlockClump::addBlock(int col,int row){ + blocks.push_back(Block({(float)col*12,(float)row*12})); +} + +void BlockClump::addBlock(vf2d offset){ blocks.push_back(Block(offset)); } diff --git a/BlockClump.h b/BlockClump.h index ccf0f9d..311d074 100644 --- a/BlockClump.h +++ b/BlockClump.h @@ -13,7 +13,8 @@ class BlockClump{ BlockClump(){} std::vector&getBlocks(); void addBlock(int col); - void addBlock(vi2d offset); + void addBlock(int col,int row); + void addBlock(vf2d offset); //Get a block's position relative to this block clump. vf2d getBlockPosition(Block&b); }; diff --git a/Board.cpp b/Board.cpp index 7255254..71a37d9 100644 --- a/Board.cpp +++ b/Board.cpp @@ -14,14 +14,23 @@ Board::Board(vi2d boardSize,float gravity,float spawnRate) void Board::spawnBlock(int col){ BlockClump c=BlockClump(); c.addBlock(col); + for(int counter=1;game->coinFlip(game->gen)==0;counter++) { + c.addBlock(col,-counter); + } if (game->coinFlip(game->gen)==0) { if (col>0) { c.addBlock(col-1); + for(int counter=1;game->coinFlip(game->gen)==0;counter++) { + c.addBlock(col-1,-counter); + } } } if (game->coinFlip(game->gen)==0) { if (colcoinFlip(game->gen)==0;counter++) { + c.addBlock(col+1,-counter); + } } } clumps.push_back(c); @@ -39,31 +48,30 @@ void Board::removeClump(int ind){ BlockClump&c=clumps[ind]; for (Block&b:c.getBlocks()){ if (b.markedForDeletion) continue; - vf2d relativePos=b.pos; - b.pos=c.getBlockPosition(b); bool emptyAirBelow=true; for (int i=0;i=b2.pos.y&&b.pos.y<=b2.pos.y+12) { + if (c.getBlockPosition(b).y+12>=b2.pos.y&&c.getBlockPosition(b).y<=b2.pos.y+12) { emptyAirBelow=false; break; } } - if (b.pos.y>=yBottom) { + if (c.getBlockPosition(b).y>=yBottom) { emptyAirBelow=false; } if (emptyAirBelow) { BlockClump c2; for (int i=0;i