diff --git a/C++ProjectTemplate b/C++ProjectTemplate index af26b4b..793e7cf 100755 Binary files a/C++ProjectTemplate and b/C++ProjectTemplate differ diff --git a/ComboOverlay.h b/ComboOverlay.h new file mode 100644 index 0000000..b24a72e --- /dev/null +++ b/ComboOverlay.h @@ -0,0 +1,10 @@ +#include "pixelGameEngine.h" + +class ComboOverlay{ + public: + vf2d pos; + int combo; + int lifetime=0; + ComboOverlay(const vf2d pos,const int combo) + :pos(pos),combo(combo){} +}; \ No newline at end of file diff --git a/Meteos.h b/Meteos.h index 42ab81a..e16c043 100644 --- a/Meteos.h +++ b/Meteos.h @@ -3,6 +3,7 @@ #include "pixelGameEngine.h" #include "Board.h" #include +#include "ComboOverlay.h" class Meteos : public olc::PixelGameEngine{ public: @@ -16,6 +17,7 @@ class Meteos : public olc::PixelGameEngine{ Board gameBoard; bool gameCanRun=true; std::map SPRITES; + std::vectorcomboDisplayList; bool OnUserCreate()override; void updateGame(float fElapsedTime); void handleInput(); diff --git a/main.cpp b/main.cpp index 7c91db3..c669777 100644 --- a/main.cpp +++ b/main.cpp @@ -288,7 +288,8 @@ void Meteos::updateGame(float fElapsedTime){ c.vspeed=gameBoard.launchSpd; c.launchTime=gameBoard.launchTime; c.combo++; - std::cout<<"Combo value is "<matchedBlockIDs; //Col followed by index @@ -474,21 +475,21 @@ void Meteos::updateGame(float fElapsedTime){ if (matchedBlockIDs.size()>0) { BlockClump c; bool firstBlock=true; - int baseBlockPos; + vf2d baseBlockPos; for (BlockMatchingInfo&info:matchedBlockIDs) { if (info.c!=-1){ Block&b=gameBoard.getBlockClumps()[info.c].getBlocks()[info.ind]; if (firstBlock) { - baseBlockPos=gameBoard.getBlockClumps()[info.c].getBlockPosition(b).y; - c.y=baseBlockPos-1; + baseBlockPos=gameBoard.getBlockClumps()[info.c].getBlockPosition(b); + c.y=baseBlockPos.y-1; firstBlock=false; } b.col=BlockColor::LAUNCHED; } else { Block&b=gameBoard.getBlocks(info.col)[info.ind]; if (firstBlock) { - baseBlockPos=b.pos.y; - c.y=baseBlockPos-1; + baseBlockPos=b.pos; + c.y=baseBlockPos.y-1; firstBlock=false; } b.col=BlockColor::LAUNCHED; @@ -502,12 +503,12 @@ void Meteos::updateGame(float fElapsedTime){ } for (int i=gameBoard.getBlockClumps()[info.c].getBlocks().size()-1;i>=0;i--) { Block&b2=gameBoard.getBlockClumps()[info.c].getBlocks()[i]; - if ((int)fmod(std::abs(std::round(gameBoard.getBlockClumps()[info.c].getBlockPosition(b2).y)-std::round(baseBlockPos)),12)!=0){ - std::cout<<"Difference is not equal to 0! Value:"<<(int)fmod(std::abs(std::round(gameBoard.getBlockClumps()[info.c].getBlockPosition(b2).y)-std::round(baseBlockPos)),12)<<" "<=0;i--){ Block&b2=gameBoard.getBlocks(info.col)[i]; if (b2.pos.y<=yPos){ - if ((int)fmod((int)b2.pos.y-(int)baseBlockPos,12)!=0){ - std::cout<<"Difference is not equal to 0! Value:"<<(int)fmod((int)b2.pos.y-(int)baseBlockPos,12)<<" "<=0;i--){ //Resolve BlockClump movements. BlockClump&c=gameBoard.getBlockClumps()[i]; @@ -634,6 +636,13 @@ void Meteos::updateGame(float fElapsedTime){ found:; } } + for (int i=comboDisplayList.size()-1;i>=0;i--){ + ComboOverlay&c=comboDisplayList[i]; + c.lifetime++; + if (c.lifetime>60){ + comboDisplayList.erase(comboDisplayList.begin()+i); + } + } } void Meteos::drawGame(float fElapsedTime,bool debugView){ @@ -662,6 +671,12 @@ void Meteos::drawGame(float fElapsedTime,bool debugView){ 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)); } } + for (int i=0;i=3)?Pixel{207,103,0}:Pixel{255,255,255,180},{0.8,0.6}); + } } int main()