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. 68
      main.cpp

@ -67,20 +67,22 @@ void Board::convertClump(int ind){
if (c.getBlockPosition(b).x==b2.pos.x) {
b2.markedForDeletion=true;
c2.addBlock(b2.pos,b2.col);
game->gameBoard.assignRandomColor(c2.getBlocks()[c2.getBlocks().size()-1]);
}
}
c2.y=c.y;
}
c2.landTime=game->gameBoard.landTime;
clumpsToAdd.push_back(c2);
} else {
for (int i=0;i<c.getBlocks().size();i++) {
Block&b2=c.getBlocks()[i];
if (c.getBlockPosition(b).x==b2.pos.x) {
b2.resetTime=game->gameBoard.landTime;
b2.pos=c.getBlockPosition(b2);
b2.pos.y=(int)(b2.pos.y+1)/12*12;
b2.markedForDeletion=true;
if (b2.col==BlockColor::LAUNCHED) {
game->gameBoard.assignRandomColor(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];
if (c.launchTime>0) {
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 {
c.vspeed+=gameBoard.gravity;
}
@ -102,25 +91,34 @@ void Meteos::updateGame(float fElapsedTime){
}
}
nextClumpCollisionCheck:;
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(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-=c.getBlockPosition(b).y+12-b2.pos.y;
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(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-=c.getBlockPosition(b).y+12-b2.pos.y;
c.vspeed=0;
if (c.landTime>=gameBoard.landTime) {
gameBoard.convertClump(i--);
} else {
c.landTime+=fElapsedTime;
}
goto nextClump;
}
}
if (c.getBlockPosition(b).y>=gameBoard.yBottom) {
c.y-=c.getBlockPosition(b).y-gameBoard.yBottom;
c.vspeed=0;
gameBoard.convertClump(i--);
if (c.landTime>=gameBoard.landTime) {
gameBoard.convertClump(i--);
} else {
c.landTime+=fElapsedTime;
}
goto nextClump;
}
}
if (c.getBlockPosition(b).y>=gameBoard.yBottom) {
c.y-=c.getBlockPosition(b).y-gameBoard.yBottom;
c.vspeed=0;
gameBoard.convertClump(i--);
goto nextClump;
}
}
c.landTime=0;
nextClump:;
}
for (BlockClump&c:gameBoard.getBlockClumps()){
@ -397,30 +395,12 @@ void Meteos::drawGame(float fElapsedTime){
BlockClump&c=gameBoard.getBlockClumps()[i];
for (int j=0;j<c.getBlocks().size();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});
}
}
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];
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});
}
}

Loading…
Cancel
Save