|
|
@ -37,9 +37,35 @@ std::vector<BlockClump>&Board::getBlockClumps(){ |
|
|
|
|
|
|
|
|
|
|
|
void Board::removeClump(int ind){ |
|
|
|
void Board::removeClump(int ind){ |
|
|
|
BlockClump&c=clumps[ind]; |
|
|
|
BlockClump&c=clumps[ind]; |
|
|
|
for (Block b:c.getBlocks()){ |
|
|
|
for (Block&b:c.getBlocks()){ |
|
|
|
cols[b.pos.x/12].push_back(b); |
|
|
|
if (b.markedForDeletion) continue; |
|
|
|
cols[b.pos.x/12][cols[b.pos.x/12].size()-1].pos=c.getBlockPosition(b); |
|
|
|
vf2d relativePos=b.pos; |
|
|
|
|
|
|
|
b.pos=c.getBlockPosition(b); |
|
|
|
|
|
|
|
bool emptyAirBelow=true; |
|
|
|
|
|
|
|
for (int i=0;i<cols[b.pos.x/12].size();i++) { |
|
|
|
|
|
|
|
Block&b2=cols[b.pos.x/12][i]; |
|
|
|
|
|
|
|
if (b.pos.y+12>=b2.pos.y&&b.pos.y<=b2.pos.y+12) { |
|
|
|
|
|
|
|
emptyAirBelow=false; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (b.pos.y>=yBottom) { |
|
|
|
|
|
|
|
emptyAirBelow=false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (emptyAirBelow) { |
|
|
|
|
|
|
|
BlockClump c2; |
|
|
|
|
|
|
|
for (int i=0;i<c.getBlocks().size();i++) { |
|
|
|
|
|
|
|
Block&b2=c.getBlocks()[i]; |
|
|
|
|
|
|
|
if (b.pos.x==b2.pos.x) { |
|
|
|
|
|
|
|
b2.markedForDeletion=true; |
|
|
|
|
|
|
|
c2.addBlock(relativePos); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
c2.y=c.y; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
clumps.push_back(c2); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
cols[b.pos.x/12].push_back(b); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
clumps.erase(clumps.begin()+ind); |
|
|
|
clumps.erase(clumps.begin()+ind); |
|
|
|
} |
|
|
|
} |