|
|
|
@ -10,6 +10,7 @@ struct BlockMatchingInfo{ |
|
|
|
|
int col; |
|
|
|
|
int ind; |
|
|
|
|
int c=-1; |
|
|
|
|
bool changeToLaunched=true; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
bool Meteos::OnUserCreate() |
|
|
|
@ -24,7 +25,7 @@ bool Meteos::OnUserCreate() |
|
|
|
|
coinFlip=std::uniform_int_distribution<>(0, 1); |
|
|
|
|
comboOverlayOffset=std::uniform_int_distribution<>(-16,16); |
|
|
|
|
|
|
|
|
|
gameBoard=Board({10,14},0.02f,0.04f,1.2f,0.04f,0.4f,{-1.f,-1.5f,-2.f,-2.5f,-4.f},1.7f,2.0f,0.2f,{3,3,1,2,3,0,0,0,0,0}, |
|
|
|
|
gameBoard=Board({10,14},0.02f,0.04f,1.2f,0.04f,0.4f,{-0.2f,-1.5f,-2.f,-2.5f,-4.f},1.7f,2.0f,0.2f,{3,3,1,2,3,0,0,0,0,0}, |
|
|
|
|
60*10,SPRITES["blocks_test.png"]); |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
@ -121,7 +122,7 @@ void Meteos::updateGame(float fElapsedTime){ |
|
|
|
|
lastBlockSpawn+=fElapsedTime; |
|
|
|
|
if (lastBlockSpawn>=gameBoard.spawnRate){ |
|
|
|
|
lastBlockSpawn-=gameBoard.spawnRate; |
|
|
|
|
gameBoard.spawnBlock(randBlockPos(gen)); |
|
|
|
|
//gameBoard.spawnBlock(randBlockPos(gen));
|
|
|
|
|
} |
|
|
|
|
for (int i=gameBoard.getBlockClumps().size()-1;i>=0;i--){ |
|
|
|
|
BlockClump&c=gameBoard.getBlockClumps()[i]; |
|
|
|
@ -298,7 +299,7 @@ void Meteos::updateGame(float fElapsedTime){ |
|
|
|
|
if (c2.landTime>0){ |
|
|
|
|
for (int j=0;j<c2.getBlocks().size();j++){ |
|
|
|
|
Block&b2=c2.getBlocks()[j]; |
|
|
|
|
if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==checkX&&b2.pos.y-c.y==checkY) { |
|
|
|
|
if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==checkX&&c2.getBlockPosition(b2).y-c.y==checkY) { |
|
|
|
|
found=true; |
|
|
|
|
checkX+=12; |
|
|
|
|
tempMatchIDsX.push_back({(int)b2.pos.x/12,j,h}); |
|
|
|
@ -332,7 +333,7 @@ void Meteos::updateGame(float fElapsedTime){ |
|
|
|
|
if (c2.landTime>0){ |
|
|
|
|
for (int j=0;j<c2.getBlocks().size();j++){ |
|
|
|
|
Block&b2=c2.getBlocks()[j]; |
|
|
|
|
if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==checkX&&b2.pos.y-c.y==checkY) { |
|
|
|
|
if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==checkX&&c2.getBlockPosition(b2).y-c.y==checkY) { |
|
|
|
|
found=true; |
|
|
|
|
checkX-=12; |
|
|
|
|
tempMatchIDsX.push_back({(int)b2.pos.x/12,j,h}); |
|
|
|
@ -366,7 +367,7 @@ void Meteos::updateGame(float fElapsedTime){ |
|
|
|
|
if (c2.landTime>0){ |
|
|
|
|
for (int j=0;j<c2.getBlocks().size();j++){ |
|
|
|
|
Block&b2=c2.getBlocks()[j]; |
|
|
|
|
if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==checkX&&b2.pos.y-c.y==checkY) { |
|
|
|
|
if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==checkX&&c2.getBlockPosition(b2).y-c.y==checkY) { |
|
|
|
|
found=true; |
|
|
|
|
checkY-=12; |
|
|
|
|
tempMatchIDsY.push_back({(int)b2.pos.x/12,j,h}); |
|
|
|
@ -400,7 +401,7 @@ void Meteos::updateGame(float fElapsedTime){ |
|
|
|
|
if (c2.landTime>0){ |
|
|
|
|
for (int j=0;j<c2.getBlocks().size();j++){ |
|
|
|
|
Block&b2=c2.getBlocks()[j]; |
|
|
|
|
if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==checkX&&b2.pos.y-c.y==checkY) { |
|
|
|
|
if (b.col==b2.col&&b2.col!=BlockColor::LAUNCHED&&b2.pos.x==checkX&&c2.getBlockPosition(b2).y-c.y==checkY) { |
|
|
|
|
found=true; |
|
|
|
|
checkY+=12; |
|
|
|
|
tempMatchIDsY.push_back({(int)b2.pos.x/12,j,h}); |
|
|
|
@ -415,6 +416,26 @@ void Meteos::updateGame(float fElapsedTime){ |
|
|
|
|
if (tempMatchIDsX.size()>2||tempMatchIDsY.size()>2) { |
|
|
|
|
if (tempMatchIDsX.size()>2) { |
|
|
|
|
for (BlockMatchingInfo i:tempMatchIDsX) { |
|
|
|
|
if (i.c!=g){ |
|
|
|
|
for (int j=0;j<gameBoard.getBlockClumps()[i.c].getBlocks().size();j++){ |
|
|
|
|
Block&bb=gameBoard.getBlockClumps()[i.c].getBlocks()[j]; |
|
|
|
|
if (!bb.addedToLaunchList&&j!=i.ind) { |
|
|
|
|
for (int k=0;k<tempMatchIDsX.size();k++){ |
|
|
|
|
if (tempMatchIDsX[k].c==i.c&&tempMatchIDsX[k].ind==j){ |
|
|
|
|
goto skipX; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
bb.addedToLaunchList=true; |
|
|
|
|
matchedBlockIDs.push_back({(int)bb.pos.x/12,j,i.c,false}); |
|
|
|
|
skipX:; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Block&bb=gameBoard.getBlockClumps()[i.c].getBlocks()[i.ind]; |
|
|
|
|
if (!bb.addedToLaunchList){ |
|
|
|
|
bb.addedToLaunchList=true; |
|
|
|
|
matchedBlockIDs.push_back(i); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
Block&bb=gameBoard.getBlockClumps()[i.c].getBlocks()[i.ind]; |
|
|
|
|
if (!bb.addedToLaunchList) { |
|
|
|
|
bb.addedToLaunchList=true; |
|
|
|
@ -422,13 +443,35 @@ void Meteos::updateGame(float fElapsedTime){ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (tempMatchIDsY.size()>2) { |
|
|
|
|
for (BlockMatchingInfo i:tempMatchIDsY) { |
|
|
|
|
if (i.c!=g){ |
|
|
|
|
for (int j=0;j<gameBoard.getBlockClumps()[i.c].getBlocks().size();j++){ |
|
|
|
|
Block&bb=gameBoard.getBlockClumps()[i.c].getBlocks()[j]; |
|
|
|
|
if (!bb.addedToLaunchList&&j!=i.ind) { |
|
|
|
|
for (int k=0;k<tempMatchIDsY.size();k++){ |
|
|
|
|
if (tempMatchIDsY[k].c==i.c&&tempMatchIDsY[k].ind==j){ |
|
|
|
|
goto skipY; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
bb.addedToLaunchList=true; |
|
|
|
|
matchedBlockIDs.push_back({(int)bb.pos.x/12,j,i.c,false}); |
|
|
|
|
skipY:; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Block&bb=gameBoard.getBlockClumps()[i.c].getBlocks()[i.ind]; |
|
|
|
|
if (!bb.addedToLaunchList){ |
|
|
|
|
bb.addedToLaunchList=true; |
|
|
|
|
matchedBlockIDs.push_back(i); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
Block&bb=gameBoard.getBlockClumps()[i.c].getBlocks()[i.ind]; |
|
|
|
|
if (!bb.addedToLaunchList) { |
|
|
|
|
bb.addedToLaunchList=true; |
|
|
|
|
matchedBlockIDs.push_back(i); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -440,10 +483,16 @@ void Meteos::updateGame(float fElapsedTime){ |
|
|
|
|
} else { |
|
|
|
|
Block&b=gameBoard.getBlockClumps()[i.c].getBlocks()[i.ind]; |
|
|
|
|
if (!b.markedForRemoval){ |
|
|
|
|
if (i.changeToLaunched){ |
|
|
|
|
b.col=BlockColor::LAUNCHED; |
|
|
|
|
c.addBlock(i.col,(gameBoard.getBlockClumps()[i.c].getBlockPosition(b).y-c.y)/12,BlockColor::LAUNCHED); |
|
|
|
|
} else { |
|
|
|
|
c.addBlock(i.col,(gameBoard.getBlockClumps()[i.c].getBlockPosition(b).y-c.y)/12,b.col); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (i.changeToLaunched){ |
|
|
|
|
b.col=BlockColor::LAUNCHED; |
|
|
|
|
} |
|
|
|
|
b.markedForRemoval=true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|