Blocks can now be launched out of the field

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent 275bc29854
commit 20f77ffd02
  1. 4
      BlockClump.cpp
  2. 1
      BlockClump.h
  3. BIN
      C++ProjectTemplate
  4. 15
      main.cpp

@ -34,4 +34,8 @@ void BlockClump::sortBlocks(){
std::sort(blocks.begin(),blocks.end(),[](Block&b1,Block&b2){
return b1.pos.y>b2.pos.y;
});
}
void BlockClump::removeBlock(int i){
blocks.erase(blocks.begin()+i);
}

@ -21,5 +21,6 @@ class BlockClump{
//Get a block's position relative to this block clump.
vf2d getBlockPosition(Block&b);
void sortBlocks();
void removeBlock(int i);
};
#endif

Binary file not shown.

@ -74,6 +74,7 @@ void Meteos::updateGame(float fElapsedTime){
c2.getBlockPosition(b2).y-c.getBlockPosition(b3).y:
c.getBlockPosition(b3).y-c2.getBlockPosition(b2).y;
c2.y+=(c2.getBlockPosition(b2).y>c.getBlockPosition(b3).y)?
yDiff:-yDiff;
float influence=(float)c.getBlocks().size()/(c.getBlocks().size()+c2.getBlocks().size());
int blockCount=c.getBlocks().size();
@ -120,7 +121,6 @@ void Meteos::updateGame(float fElapsedTime){
goto nextClump;
}
}
c.y+=c.vspeed;
nextClump:;
}
for (BlockClump&c:gameBoard.getBlockClumps()){
@ -357,6 +357,19 @@ void Meteos::updateGame(float fElapsedTime){
}
gameBoard.addClump(c);
}
for (int i=0;i<gameBoard.getBlockClumps().size();i++){ //Resolve BlockClump movements.
BlockClump&c=gameBoard.getBlockClumps()[i];
if (c.vspeed<0) {
for (int j=0;j<c.getBlocks().size();j++){
Block&b=c.getBlocks()[j];
if (c.getBlockPosition(b).y<0){
c.removeBlock(j--);
break;
}
}
}
c.y+=c.vspeed;
}
for (int i=0;i<gameBoard.boardSize.x;i++){
for (int y=0;y<gameBoard.getBlocks(i).size();y++){
Block&b=gameBoard.getBlocks(i)[y];

Loading…
Cancel
Save