Clumps can now match on each other

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 80328a7855
commit f64f41318a
  1. BIN
      C++ProjectTemplate
  2. 88
      main.cpp

Binary file not shown.

@ -291,6 +291,24 @@ void Meteos::updateGame(float fElapsedTime){
break; break;
} }
} }
if (c.landTime>0){
for (int h=0;h<gameBoard.getBlockClumps().size();h++){
if (g==h)continue;
BlockClump&c2=gameBoard.getBlockClumps()[h];
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==checkY) {
found=true;
checkX+=12;
tempMatchIDsX.push_back({(int)b2.pos.x/12,j,h});
goto outerRightCheck;
}
}
}
}
}
outerRightCheck:;
}while(found); }while(found);
leftCheck: leftCheck:
checkX=targetX-12; checkX=targetX-12;
@ -307,6 +325,23 @@ void Meteos::updateGame(float fElapsedTime){
break; break;
} }
} }
if (c.landTime>0){
for (int h=0;h<gameBoard.getBlockClumps().size();h++){
if (g==h)continue;
BlockClump&c2=gameBoard.getBlockClumps()[h];
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==checkY) {
found=true;
checkX-=12;
tempMatchIDsX.push_back({(int)b2.pos.x/12,j,h});
goto outerRightCheck;
}
}
}
}
}
}while(found); }while(found);
upCheck: upCheck:
checkX=targetX; checkX=targetX;
@ -323,6 +358,23 @@ void Meteos::updateGame(float fElapsedTime){
break; break;
} }
} }
if (c.landTime>0){
for (int h=0;h<gameBoard.getBlockClumps().size();h++){
if (g==h)continue;
BlockClump&c2=gameBoard.getBlockClumps()[h];
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==checkY) {
found=true;
checkY-=12;
tempMatchIDsY.push_back({(int)b2.pos.x/12,j,h});
goto outerRightCheck;
}
}
}
}
}
}while(found); }while(found);
downCheck: downCheck:
checkX=targetX; checkX=targetX;
@ -339,6 +391,23 @@ void Meteos::updateGame(float fElapsedTime){
break; break;
} }
} }
if (c.landTime>0){
for (int h=0;h<gameBoard.getBlockClumps().size();h++){
if (g==h)continue;
BlockClump&c2=gameBoard.getBlockClumps()[h];
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==checkY) {
found=true;
checkY+=12;
tempMatchIDsY.push_back({(int)b2.pos.x/12,j,h});
goto outerRightCheck;
}
}
}
}
}
}while(found); }while(found);
if (tempMatchIDsX.size()>2||tempMatchIDsY.size()>2) { if (tempMatchIDsX.size()>2||tempMatchIDsY.size()>2) {
if (tempMatchIDsX.size()>2) { if (tempMatchIDsX.size()>2) {
@ -362,8 +431,18 @@ void Meteos::updateGame(float fElapsedTime){
} }
} }
for (BlockMatchingInfo i:matchedBlockIDs) { for (BlockMatchingInfo i:matchedBlockIDs) {
if (g==i.c){
Block&b=gameBoard.getBlockClumps()[i.c].getBlocks()[i.ind]; Block&b=gameBoard.getBlockClumps()[i.c].getBlocks()[i.ind];
b.col=BlockColor::LAUNCHED; b.col=BlockColor::LAUNCHED;
} else {
Block&b=gameBoard.getBlockClumps()[i.c].getBlocks()[i.ind];
if (!b.markedForRemoval){
b.col=BlockColor::LAUNCHED;
c.addBlock(i.col,(gameBoard.getBlockClumps()[i.c].getBlockPosition(b).y-c.y)/12,BlockColor::LAUNCHED);
}
b.col=BlockColor::LAUNCHED;
b.markedForRemoval=true;
}
} }
if (matchedBlockIDs.size()>0){ if (matchedBlockIDs.size()>0){
c.vspeed=gameBoard.launchSpd[std::min(c.combo,(int)gameBoard.launchSpd.size()-1)]/(1+(c.getBlocks().size()*gameBoard.blockWeight)); c.vspeed=gameBoard.launchSpd[std::min(c.combo,(int)gameBoard.launchSpd.size()-1)]/(1+(c.getBlocks().size()*gameBoard.blockWeight));
@ -374,6 +453,15 @@ void Meteos::updateGame(float fElapsedTime){
//std::cout<<"Combo value is "<<c.combo<<std::endl; //std::cout<<"Combo value is "<<c.combo<<std::endl;
} }
} }
for (int g=0;g<gameBoard.getBlockClumps().size();g++){
BlockClump&c=gameBoard.getBlockClumps()[g];
for (int i=0;i<c.getBlocks().size();i++){
Block&b=c.getBlocks()[i];
if (b.markedForRemoval){
c.removeBlock(i--);
}
}
}
std::vector<BlockMatchingInfo>matchedBlockIDs; //Col followed by index std::vector<BlockMatchingInfo>matchedBlockIDs; //Col followed by index
for (int i=0;i<gameBoard.boardSize.x;i++){ for (int i=0;i<gameBoard.boardSize.x;i++){
for (Block&b:gameBoard.getBlocks(i)) { for (Block&b:gameBoard.getBlocks(i)) {

Loading…
Cancel
Save