Changed block conversion behavior to be after landing

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent da193146b7
commit 12837487c6
  1. 6
      Board.cpp
  2. BIN
      C++ProjectTemplate
  3. 38
      main.cpp

@ -67,20 +67,22 @@ void Board::convertClump(int ind){
if (c.getBlockPosition(b).x==b2.pos.x) { if (c.getBlockPosition(b).x==b2.pos.x) {
b2.markedForDeletion=true; b2.markedForDeletion=true;
c2.addBlock(b2.pos,b2.col); c2.addBlock(b2.pos,b2.col);
game->gameBoard.assignRandomColor(c2.getBlocks()[c2.getBlocks().size()-1]);
} }
} }
c2.y=c.y; c2.y=c.y;
} }
c2.landTime=game->gameBoard.landTime;
clumpsToAdd.push_back(c2); clumpsToAdd.push_back(c2);
} else { } else {
for (int i=0;i<c.getBlocks().size();i++) { for (int i=0;i<c.getBlocks().size();i++) {
Block&b2=c.getBlocks()[i]; Block&b2=c.getBlocks()[i];
if (c.getBlockPosition(b).x==b2.pos.x) { if (c.getBlockPosition(b).x==b2.pos.x) {
b2.resetTime=game->gameBoard.landTime;
b2.pos=c.getBlockPosition(b2); b2.pos=c.getBlockPosition(b2);
b2.pos.y=(int)(b2.pos.y+1)/12*12; b2.pos.y=(int)(b2.pos.y+1)/12*12;
b2.markedForDeletion=true; b2.markedForDeletion=true;
if (b2.col==BlockColor::LAUNCHED) {
game->gameBoard.assignRandomColor(b2);
}
cols[b.pos.x/12].push_back(b2); cols[b.pos.x/12].push_back(b2);
} }
} }

Binary file not shown.

@ -43,17 +43,6 @@ void Meteos::updateGame(float fElapsedTime){
BlockClump&c=gameBoard.getBlockClumps()[i]; BlockClump&c=gameBoard.getBlockClumps()[i];
if (c.launchTime>0) { if (c.launchTime>0) {
c.launchTime-=fElapsedTime; c.launchTime-=fElapsedTime;
} else
if (c.landTime>0) {
c.landTime-=fElapsedTime;
if (c.landTime<=0) {
c.landTime=0;
for (int j=0;j<c.getBlocks().size();j++){
if (c.getBlocks()[j].col==BlockColor::LAUNCHED) {
gameBoard.assignRandomColor(c.getBlocks()[j]);
}
}
}
} else { } else {
c.vspeed+=gameBoard.gravity; c.vspeed+=gameBoard.gravity;
} }
@ -110,17 +99,26 @@ void Meteos::updateGame(float fElapsedTime){
if (c.getBlockPosition(b).y+12>=b2.pos.y&&c.getBlockPosition(b).y<=b2.pos.y+12){ if (c.getBlockPosition(b).y+12>=b2.pos.y&&c.getBlockPosition(b).y<=b2.pos.y+12){
c.y-=c.getBlockPosition(b).y+12-b2.pos.y; c.y-=c.getBlockPosition(b).y+12-b2.pos.y;
c.vspeed=0; c.vspeed=0;
if (c.landTime>=gameBoard.landTime) {
gameBoard.convertClump(i--); gameBoard.convertClump(i--);
} else {
c.landTime+=fElapsedTime;
}
goto nextClump; goto nextClump;
} }
} }
if (c.getBlockPosition(b).y>=gameBoard.yBottom) { if (c.getBlockPosition(b).y>=gameBoard.yBottom) {
c.y-=c.getBlockPosition(b).y-gameBoard.yBottom; c.y-=c.getBlockPosition(b).y-gameBoard.yBottom;
c.vspeed=0; c.vspeed=0;
if (c.landTime>=gameBoard.landTime) {
gameBoard.convertClump(i--); gameBoard.convertClump(i--);
} else {
c.landTime+=fElapsedTime;
}
goto nextClump; goto nextClump;
} }
} }
c.landTime=0;
nextClump:; nextClump:;
} }
for (BlockClump&c:gameBoard.getBlockClumps()){ for (BlockClump&c:gameBoard.getBlockClumps()){
@ -397,30 +395,12 @@ void Meteos::drawGame(float fElapsedTime){
BlockClump&c=gameBoard.getBlockClumps()[i]; BlockClump&c=gameBoard.getBlockClumps()[i];
for (int j=0;j<c.getBlocks().size();j++){ for (int j=0;j<c.getBlocks().size();j++){
Block&b=c.getBlocks()[j]; Block&b=c.getBlocks()[j];
if (b.resetTime>0) {
b.resetTime-=fElapsedTime;
if (b.resetTime<0) {
b.resetTime=0;
if (b.col==BlockColor::LAUNCHED) {
gameBoard.assignRandomColor(b);
}
}
}
DrawPartialDecal(c.getBlockPosition(b)+gameBoard.drawOffset,gameBoard.tileset,{(float)(int)b.col*12,0},{12,12}); DrawPartialDecal(c.getBlockPosition(b)+gameBoard.drawOffset,gameBoard.tileset,{(float)(int)b.col*12,0},{12,12});
} }
} }
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];
if (b.resetTime>0) {
b.resetTime-=fElapsedTime;
if (b.resetTime<0) {
b.resetTime=0;
if (b.col==BlockColor::LAUNCHED) {
gameBoard.assignRandomColor(b);
}
}
}
DrawPartialDecal(b.pos+gameBoard.drawOffset,gameBoard.tileset,{(float)(int)b.col*12,0},{12,12}); DrawPartialDecal(b.pos+gameBoard.drawOffset,gameBoard.tileset,{(float)(int)b.col*12,0},{12,12});
} }
} }

Loading…
Cancel
Save