diff --git a/C++ProjectTemplate b/C++ProjectTemplate index 9645ae2..e36e177 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/Meteos.h b/Meteos.h index 86b756f..b414d73 100644 --- a/Meteos.h +++ b/Meteos.h @@ -23,5 +23,15 @@ class Meteos : public olc::PixelGameEngine{ void handleInput(); void drawGame(float fElapsedTime,bool debugView); bool OnUserUpdate(float fElapsedTime)override; + void spawnBlocks(float fElapsedTime); + void handleBlockGravity(float fElapsedTime); + void matchBlocks(); + void matchFlyingBlockClumps(); + void cleanupBlockClumps(); + void matchGroundedBlocks(); + void cleanupBlocks(); + void handleWarningLevels(float fElapsedTime); + void validateSelectedBlock(); + void handleComboAnimations(); }; #endif \ No newline at end of file diff --git a/main.cpp b/main.cpp index c718d40..2d73ca7 100644 --- a/main.cpp +++ b/main.cpp @@ -25,7 +25,7 @@ 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,{-0.2f,-1.5f,-2.f,-2.5f,-4.f},1.7f,2.0f,0.2f,{3,3,1,2,3,0,0,0,0,0}, + 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,0.2f,{3,3,1,2,3,0,0,0,0,0}, 60*10,SPRITES["blocks_test.png"]); return true; @@ -118,12 +118,15 @@ void Meteos::handleInput(){ } } -void Meteos::updateGame(float fElapsedTime){ +void Meteos::spawnBlocks(float fElapsedTime){ lastBlockSpawn+=fElapsedTime; if (lastBlockSpawn>=gameBoard.spawnRate){ lastBlockSpawn-=gameBoard.spawnRate; - //gameBoard.spawnBlock(randBlockPos(gen)); + gameBoard.spawnBlock(randBlockPos(gen)); } +} + +void Meteos::handleBlockGravity(float fElapsedTime){ for (int i=gameBoard.getBlockClumps().size()-1;i>=0;i--){ BlockClump&c=gameBoard.getBlockClumps()[i]; if (c.launchTime>0) { @@ -262,6 +265,9 @@ void Meteos::updateGame(float fElapsedTime){ c.landTime=0; nextClump:; } +} + +void Meteos::matchFlyingBlockClumps(){ for (int g=0;gmatchedBlockIDs; @@ -505,6 +511,9 @@ void Meteos::updateGame(float fElapsedTime){ //std::cout<<"Combo value is "<matchedBlockIDs; //Col followed by index for (int i=0;i=0;i--){ //Resolve BlockClump movements. BlockClump&c=gameBoard.getBlockClumps()[i]; for (int j=c.getBlocks().size()-1;j>=0;j--){ @@ -770,7 +791,6 @@ void Meteos::updateGame(float fElapsedTime){ if (c.vspeed<0&&c.getBlockPosition(b).y<0||b.markedForRemoval){ std::cout<<"Removed block @"<=gameBoard.boardSize.y){ @@ -812,23 +835,27 @@ void Meteos::updateGame(float fElapsedTime){ } } gameBoard.warningLevel=0; - goto invalidatedExit; } +} + +void Meteos::validateSelectedBlock(){ //Invalidate the selected block if something is strange about it. if (gameBoard.selectedBlock.col!=-1){ if (gameBoard.selectedBlock.c!=-1){ if (!(gameBoard.selectedBlock.c=0;i--){ ComboOverlay&c=comboDisplayList[i]; c.lifetime++; @@ -839,6 +866,16 @@ void Meteos::updateGame(float fElapsedTime){ } } +void Meteos::updateGame(float fElapsedTime){ + spawnBlocks(fElapsedTime); + handleBlockGravity(fElapsedTime); + matchBlocks(); + cleanupBlocks(); + handleWarningLevels(fElapsedTime); + validateSelectedBlock(); + handleComboAnimations(); +} + void Meteos::drawGame(float fElapsedTime,bool debugView){ Clear(Pixel(32,32,255)); for (int x=-1;x<=gameBoard.boardSize.x;x++){