Added topping out

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent d6f46ba81b
commit ebcacc5381
  1. 8
      Board.cpp
  2. 3
      Board.h
  3. BIN
      C++ProjectTemplate
  4. 30
      main.cpp

@ -5,8 +5,10 @@ extern Meteos*game;
Board::Board()
:colorHandler({}){}
Board::Board(vi2d boardSize,float blockWeight,float gravity,float maxGravity,float comboGravity,float comboMaxGravity,std::vector<float> launchSpd,float launchTime,float landTime,float spawnRate,std::array<int,10> colorRates,Renderable&tileset)
:boardSize(boardSize),blockWeight(blockWeight),gravity(gravity),maxGravity(maxGravity),comboGravity(comboGravity),comboMaxGravity(comboMaxGravity),launchSpd(launchSpd),launchTime(launchTime),landTime(landTime),spawnRate(spawnRate),colorHandler(colorRates),tileset(tileset.Decal()){
Board::Board(vi2d boardSize,float blockWeight,float gravity,float maxGravity,float comboGravity,float comboMaxGravity,std::vector<float> launchSpd,float launchTime,float landTime,float spawnRate,std::array<int,10> colorRates,
int maxWarningLevel,Renderable&tileset)
:boardSize(boardSize),blockWeight(blockWeight),gravity(gravity),maxGravity(maxGravity),comboGravity(comboGravity),comboMaxGravity(comboMaxGravity),launchSpd(launchSpd),launchTime(launchTime),landTime(landTime),spawnRate(spawnRate),colorHandler(colorRates),tileset(tileset.Decal()),
maxWarningLevel(maxWarningLevel){
drawOffset={(float)game->ScreenWidth()/2-boardSize.x/2*12,(float)game->ScreenHeight()/2-boardSize.y/2*12};
yBottom=(boardSize.y-1)*12;
for (int i=0;i<boardSize.x;i++) {
@ -81,11 +83,13 @@ void Board::convertClump(int ind){
if (b2.col==BlockColor::LAUNCHED) {
game->gameBoard.assignRandomColor(b2);
}
if (cols[b.pos.x/12].size()<game->gameBoard.boardSize.y){
cols[b.pos.x/12].push_back(b2);
}
}
}
}
}
for (BlockClump&bc:clumpsToAdd) {
bc.sortBlocks();
clumps.push_back(bc);

@ -57,7 +57,8 @@ class Board{
int maxWarningLevel=0;
std::vector<float> warningFlashingLevel;
Board();
Board(vi2d boardSize,float blockWeight,float gravity,float maxGravity,float launchedGravity,float launchedMaxGravity,std::vector<float> launchSpd,float launchTime,float landTime,float spawnRate,std::array<int,10> colorRates,Renderable&tileset);
Board(vi2d boardSize,float blockWeight,float gravity,float maxGravity,float launchedGravity,float launchedMaxGravity,std::vector<float> launchSpd,float launchTime,float landTime,float spawnRate,std::array<int,10> colorRates,
int maxWarningLevel,Renderable&tileset);
void spawnBlock(int col);
void addClump(BlockClump&c);
std::vector<Block>&getBlocks(int col);

Binary file not shown.

@ -24,7 +24,8 @@ bool Meteos::OnUserCreate()
coinFlip=std::uniform_int_distribution<>(0, 1);
comboOverlayOffset=std::uniform_int_distribution<>(-16,16);
gameBoard=Board({10,14},0.02f,0.04f,1.2f,0.04f,0.4f,{-1.f,-1.5f,-2.f,-2.5f,-4.f},1.7f,2.0f,1.0f,{3,3,1,2,3,0,0,0,0,0},SPRITES["blocks_test.png"]);
gameBoard=Board({10,14},0.02f,0.04f,1.2f,0.04f,0.4f,{-1.f,-1.5f,-2.f,-2.5f,-4.f},1.7f,2.0f,1.0f,{3,3,1,2,3,0,0,0,0,0},
60*10,SPRITES["blocks_test.png"]);
return true;
}
@ -614,7 +615,15 @@ void Meteos::updateGame(float fElapsedTime){
continue;
}
}
bool noWarning=true;
for (int i=0;i<gameBoard.boardSize.x;i++){
if (gameBoard.getBlocks(i).size()>=gameBoard.boardSize.y){
gameBoard.warningFlashingLevel[i]+=fElapsedTime;
gameBoard.warningLevel++;
noWarning=false;
} else {
gameBoard.warningFlashingLevel[i]=0;
}
for (int y=gameBoard.getBlocks(i).size()-1;y>=0;y--){
Block&b=gameBoard.getBlocks(i)[y];
b.addedToLaunchList=false;
@ -624,6 +633,22 @@ void Meteos::updateGame(float fElapsedTime){
}
}
}
if (noWarning){
gameBoard.warningLevel=0;
} else
if (gameBoard.warningLevel>=gameBoard.maxWarningLevel){
//Planet crashes! For now we just clear all blocks and clumps on the board.
while (gameBoard.getBlockClumps().size()>0){
gameBoard.removeClump(0);
}
for (int i=0;i<gameBoard.boardSize.x;i++){
while (gameBoard.getBlocks(i).size()>0){
gameBoard.removeBlock(i,0);
}
}
gameBoard.warningLevel=0;
goto invalidatedExit;
}
//Invalidate the selected block if something is strange about it.
if (gameBoard.selectedBlock.col!=-1){
if (gameBoard.selectedBlock.c!=-1){
@ -674,6 +699,9 @@ void Meteos::drawGame(float fElapsedTime,bool debugView){
Block&b=gameBoard.getBlocks(i)[y];
DrawPartialDecal(b.pos+gameBoard.drawOffset,gameBoard.tileset,{(float)(int)b.col*12,0},{12,12},{1,1},gameBoard.selectedBlock.col!=-1&&gameBoard.selectedBlock.c==-1&&gameBoard.selectedBlock.col==i&&gameBoard.selectedBlock.ind==y?Pixel(GREY.r,GREY.g,GREY.b,alpha):Pixel(WHITE.r,WHITE.g,WHITE.b,alpha));
}
if (gameBoard.warningFlashingLevel[i]>0){
FillRectDecal({gameBoard.drawOffset.x+i*12,gameBoard.drawOffset.y},{12,(float)gameBoard.boardSize.y*12},Pixel(255,64,64,std::abs(sin(gameBoard.warningFlashingLevel[i]*M_PI))*128));
}
}
for (int i=0;i<comboDisplayList.size();i++){
ComboOverlay&c=comboDisplayList[i];

Loading…
Cancel
Save