|
|
|
@ -12,6 +12,7 @@ bool Meteos::OnUserCreate() |
|
|
|
|
std::random_device rd; //Will be used to obtain a seed for the random number engine
|
|
|
|
|
gen=std::mt19937(rd()); //Standard mersenne_twister_engine seeded with rd()
|
|
|
|
|
randBlockPos=std::uniform_int_distribution<>(0, 9); |
|
|
|
|
coinFlip=std::uniform_int_distribution<>(0, 1); |
|
|
|
|
|
|
|
|
|
gameBoard=Board({10,14},12.f,3.0f); |
|
|
|
|
return true; |
|
|
|
@ -40,28 +41,28 @@ bool Meteos::OnUserUpdate(float fElapsedTime) |
|
|
|
|
for (int j=0;j<c.getBlocks().size();j++){ |
|
|
|
|
Block&b=c.getBlocks()[j]; |
|
|
|
|
int col=b.pos.x/12; |
|
|
|
|
for (int k=0;k<gameBoard.getBlocks(j).size();k++){ |
|
|
|
|
Block&b2=gameBoard.getBlocks(j)[k]; |
|
|
|
|
for (int k=0;k<gameBoard.getBlocks(col).size();k++){ |
|
|
|
|
Block&b2=gameBoard.getBlocks(col)[k]; |
|
|
|
|
if (c.getBlockPosition(b).y+12>=b2.pos.y&&c.getBlockPosition(b).y<=b2.pos.y+12){ |
|
|
|
|
c.y=b2.pos.y-12; |
|
|
|
|
c.vspeed=0; |
|
|
|
|
gameBoard.removeClump(c); |
|
|
|
|
i--; |
|
|
|
|
gameBoard.removeClump(i--); |
|
|
|
|
goto nextClump; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (c.getBlockPosition(b).y>=gameBoard.yBottom) { |
|
|
|
|
c.y=gameBoard.yBottom; |
|
|
|
|
c.vspeed=0; |
|
|
|
|
gameBoard.removeClump(c); |
|
|
|
|
i--; |
|
|
|
|
gameBoard.removeClump(i--); |
|
|
|
|
goto nextClump; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
applyVelocity: |
|
|
|
|
for (int j=0;j<c.getBlocks().size();j++){ |
|
|
|
|
Block&b=c.getBlocks()[j]; |
|
|
|
|
c.y+=c.vspeed*fElapsedTime; |
|
|
|
|
FillRectDecal(c.getBlockPosition(b)+gameBoard.drawOffset,{12,12},DARK_GREEN); |
|
|
|
|
} |
|
|
|
|
nextClump:; |
|
|
|
|
} |
|
|
|
|
for (int i=0;i<gameBoard.boardSize.x;i++){ |
|
|
|
|
for (int y=0;y<gameBoard.getBlocks(i).size();y++){ |
|
|
|
|