|
|
|
@ -16,7 +16,7 @@ bool Meteos::OnUserCreate() |
|
|
|
|
randBlockPos=std::uniform_int_distribution<>(0, 9); |
|
|
|
|
coinFlip=std::uniform_int_distribution<>(0, 1); |
|
|
|
|
|
|
|
|
|
gameBoard=Board({10,14},20.f,100.f,-20.f,1.0f,{3,3,2,3,2,0,0,0,0,0},SPRITES["blocks_test.png"]); |
|
|
|
|
gameBoard=Board({10,14},20.f,100.f,-20.f,1.0f,{3,0,0,0,0,0,0,0,0,0},SPRITES["blocks_test.png"]); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
@ -185,8 +185,99 @@ bool Meteos::OnUserUpdate(float fElapsedTime) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (int i=0;i<gameBoard.boardSize.x;i++){ |
|
|
|
|
for (Block&b:gameBoard.getBlocks(i)) { |
|
|
|
|
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); |
|
|
|
|
rightCheckGrounded: |
|
|
|
|
float checkX=targetX+12; |
|
|
|
|
float checkY=targetY; |
|
|
|
|
do{ |
|
|
|
|
found=false; |
|
|
|
|
for (Block&b2:gameBoard.getBlocks(i)){ |
|
|
|
|
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); |
|
|
|
|
leftCheckGrounded: |
|
|
|
|
checkX=targetX-12; |
|
|
|
|
checkY=targetY; |
|
|
|
|
do{ |
|
|
|
|
found=false; |
|
|
|
|
for (Block&b2:gameBoard.getBlocks(i)){ |
|
|
|
|
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); |
|
|
|
|
upCheckGrounded: |
|
|
|
|
checkX=targetX; |
|
|
|
|
checkY=targetY-12; |
|
|
|
|
do{ |
|
|
|
|
found=false; |
|
|
|
|
for (Block&b2:gameBoard.getBlocks(i)){ |
|
|
|
|
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); |
|
|
|
|
downCheckGrounded: |
|
|
|
|
checkX=targetX; |
|
|
|
|
checkY=targetY+12; |
|
|
|
|
do{ |
|
|
|
|
found=false; |
|
|
|
|
for (Block&b2:gameBoard.getBlocks(i)){ |
|
|
|
|
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||matchedBlocksY.size()>2) { |
|
|
|
|
BlockClump c; |
|
|
|
|
c.y=b.pos.y-1; |
|
|
|
|
if (matchedBlocksX.size()>2) { |
|
|
|
|
for (Block*b2:matchedBlocksX) { |
|
|
|
|
b2->col=BlockColor::LAUNCHED; |
|
|
|
|
c.addBlockOnTopOf(b2->pos.x/12,b2->col); |
|
|
|
|
b2->markedForRemoval=true; |
|
|
|
|
} |
|
|
|
|
c.vspeed=gameBoard.launchSpd; |
|
|
|
|
} |
|
|
|
|
if (matchedBlocksY.size()>2) { |
|
|
|
|
for (int i=0;i<matchedBlocksY.size();i++) { |
|
|
|
|
Block*b2=matchedBlocksY[i]; |
|
|
|
|
b2->col=BlockColor::LAUNCHED; |
|
|
|
|
c.addBlockOnTopOf(b2->pos.x/12,b2->col); |
|
|
|
|
b2->markedForRemoval=true; |
|
|
|
|
} |
|
|
|
|
c.vspeed=gameBoard.launchSpd; |
|
|
|
|
} |
|
|
|
|
gameBoard.addClump(c); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (int y=0;y<gameBoard.getBlocks(i).size();y++){ |
|
|
|
|
Block&b=gameBoard.getBlocks(i)[y]; |
|
|
|
|
if (b.markedForRemoval){ |
|
|
|
|
gameBoard.removeBlock(i,y--); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
DrawPartialDecal(b.pos+gameBoard.drawOffset,gameBoard.tileset,{(float)(int)b.col*12,0},{12,12}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|