|
|
@ -16,7 +16,7 @@ bool Meteos::OnUserCreate() |
|
|
|
randBlockPos=std::uniform_int_distribution<>(0, 9); |
|
|
|
randBlockPos=std::uniform_int_distribution<>(0, 9); |
|
|
|
coinFlip=std::uniform_int_distribution<>(0, 1); |
|
|
|
coinFlip=std::uniform_int_distribution<>(0, 1); |
|
|
|
|
|
|
|
|
|
|
|
gameBoard=Board({10,14},12.f,3.0f,{3,3,2,3,2,3,0,0,0,0},SPRITES["blocks_test.png"]); |
|
|
|
gameBoard=Board({10,14},12.f,-20.f,3.0f,{3,0,0,0,0,0,0,0,0,0},SPRITES["blocks_test.png"]); |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
@ -102,6 +102,83 @@ bool Meteos::OnUserUpdate(float fElapsedTime) |
|
|
|
} |
|
|
|
} |
|
|
|
nextClump:; |
|
|
|
nextClump:; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for (BlockClump&c:gameBoard.getBlockClumps()){ |
|
|
|
|
|
|
|
for (Block&b:c.getBlocks()) { |
|
|
|
|
|
|
|
float targetX=b.pos.x; |
|
|
|
|
|
|
|
float targetY=b.pos.y; |
|
|
|
|
|
|
|
bool found=false; |
|
|
|
|
|
|
|
std::vector<Block*>matchedBlocksX; |
|
|
|
|
|
|
|
std::vector<Block*>matchedBlocksY; |
|
|
|
|
|
|
|
matchedBlocksX.push_back(&b); |
|
|
|
|
|
|
|
matchedBlocksY.push_back(&b); |
|
|
|
|
|
|
|
rightCheck: |
|
|
|
|
|
|
|
float checkX=targetX+12; |
|
|
|
|
|
|
|
float checkY=targetY; |
|
|
|
|
|
|
|
do{ |
|
|
|
|
|
|
|
found=false; |
|
|
|
|
|
|
|
for (Block&b2:c.getBlocks()){ |
|
|
|
|
|
|
|
if (b.pos.x==b2.pos.x&&b.pos.y==b2.pos.y)continue; |
|
|
|
|
|
|
|
if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==checkX&&b2.pos.y==checkY) { |
|
|
|
|
|
|
|
found=true; |
|
|
|
|
|
|
|
checkX+=12; |
|
|
|
|
|
|
|
matchedBlocksX.push_back(&b2); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}while(found); |
|
|
|
|
|
|
|
leftCheck: |
|
|
|
|
|
|
|
checkX=targetX-12; |
|
|
|
|
|
|
|
checkY=targetY; |
|
|
|
|
|
|
|
do{ |
|
|
|
|
|
|
|
found=false; |
|
|
|
|
|
|
|
for (Block&b2:c.getBlocks()){ |
|
|
|
|
|
|
|
if (b.pos.x==b2.pos.x&&b.pos.y==b2.pos.y)continue; |
|
|
|
|
|
|
|
if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==checkX&&b2.pos.y==checkY) { |
|
|
|
|
|
|
|
found=true; |
|
|
|
|
|
|
|
checkX-=12; |
|
|
|
|
|
|
|
matchedBlocksX.push_back(&b2); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}while(found); |
|
|
|
|
|
|
|
upCheck: |
|
|
|
|
|
|
|
checkX=targetX; |
|
|
|
|
|
|
|
checkY=targetY-12; |
|
|
|
|
|
|
|
do{ |
|
|
|
|
|
|
|
found=false; |
|
|
|
|
|
|
|
for (Block&b2:c.getBlocks()){ |
|
|
|
|
|
|
|
if (b.pos.x==b2.pos.x&&b.pos.y==b2.pos.y)continue; |
|
|
|
|
|
|
|
if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==checkX&&b2.pos.y==checkY) { |
|
|
|
|
|
|
|
found=true; |
|
|
|
|
|
|
|
checkY-=12; |
|
|
|
|
|
|
|
matchedBlocksY.push_back(&b2); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}while(found); |
|
|
|
|
|
|
|
downCheck: |
|
|
|
|
|
|
|
checkX=targetX; |
|
|
|
|
|
|
|
checkY=targetY+12; |
|
|
|
|
|
|
|
do{ |
|
|
|
|
|
|
|
found=false; |
|
|
|
|
|
|
|
for (Block&b2:c.getBlocks()){ |
|
|
|
|
|
|
|
if (b.pos.x==b2.pos.x&&b.pos.y==b2.pos.y)continue; |
|
|
|
|
|
|
|
if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==checkX&&b2.pos.y==checkY) { |
|
|
|
|
|
|
|
found=true; |
|
|
|
|
|
|
|
checkY+=12; |
|
|
|
|
|
|
|
matchedBlocksY.push_back(&b2); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}while(found); |
|
|
|
|
|
|
|
if (matchedBlocksX.size()>2) { |
|
|
|
|
|
|
|
for (Block*b2:matchedBlocksX) { |
|
|
|
|
|
|
|
b2->col=BlockColor::LAUNCHED; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (matchedBlocksY.size()>2) { |
|
|
|
|
|
|
|
for (Block*b2:matchedBlocksY) { |
|
|
|
|
|
|
|
b2->col=BlockColor::LAUNCHED; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
for (int i=0;i<gameBoard.boardSize.x;i++){ |
|
|
|
for (int i=0;i<gameBoard.boardSize.x;i++){ |
|
|
|
for (int y=0;y<gameBoard.getBlocks(i).size();y++){ |
|
|
|
for (int y=0;y<gameBoard.getBlocks(i).size();y++){ |
|
|
|
Block&b=gameBoard.getBlocks(i)[y]; |
|
|
|
Block&b=gameBoard.getBlocks(i)[y]; |
|
|
|