generated from sigonasr2/CPlusPlusProjectTemplate
Blocks can now be launched out of the field
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
275bc29854
commit
20f77ffd02
@ -35,3 +35,7 @@ void BlockClump::sortBlocks(){
|
|||||||
return b1.pos.y>b2.pos.y;
|
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.
|
//Get a block's position relative to this block clump.
|
||||||
vf2d getBlockPosition(Block&b);
|
vf2d getBlockPosition(Block&b);
|
||||||
void sortBlocks();
|
void sortBlocks();
|
||||||
|
void removeBlock(int i);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
Binary file not shown.
15
main.cpp
15
main.cpp
@ -74,6 +74,7 @@ void Meteos::updateGame(float fElapsedTime){
|
|||||||
c2.getBlockPosition(b2).y-c.getBlockPosition(b3).y:
|
c2.getBlockPosition(b2).y-c.getBlockPosition(b3).y:
|
||||||
c.getBlockPosition(b3).y-c2.getBlockPosition(b2).y;
|
c.getBlockPosition(b3).y-c2.getBlockPosition(b2).y;
|
||||||
c2.y+=(c2.getBlockPosition(b2).y>c.getBlockPosition(b3).y)?
|
c2.y+=(c2.getBlockPosition(b2).y>c.getBlockPosition(b3).y)?
|
||||||
|
|
||||||
yDiff:-yDiff;
|
yDiff:-yDiff;
|
||||||
float influence=(float)c.getBlocks().size()/(c.getBlocks().size()+c2.getBlocks().size());
|
float influence=(float)c.getBlocks().size()/(c.getBlocks().size()+c2.getBlocks().size());
|
||||||
int blockCount=c.getBlocks().size();
|
int blockCount=c.getBlocks().size();
|
||||||
@ -120,7 +121,6 @@ void Meteos::updateGame(float fElapsedTime){
|
|||||||
goto nextClump;
|
goto nextClump;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.y+=c.vspeed;
|
|
||||||
nextClump:;
|
nextClump:;
|
||||||
}
|
}
|
||||||
for (BlockClump&c:gameBoard.getBlockClumps()){
|
for (BlockClump&c:gameBoard.getBlockClumps()){
|
||||||
@ -357,6 +357,19 @@ void Meteos::updateGame(float fElapsedTime){
|
|||||||
}
|
}
|
||||||
gameBoard.addClump(c);
|
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 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];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user