|
|
|
@ -2,6 +2,7 @@ |
|
|
|
|
#include "pixelGameEngine.h" |
|
|
|
|
#include <random> |
|
|
|
|
#include "gameDefines.h" |
|
|
|
|
#include <assert.h> |
|
|
|
|
|
|
|
|
|
Meteos*game; |
|
|
|
|
|
|
|
|
@ -12,7 +13,7 @@ bool Meteos::OnUserCreate() |
|
|
|
|
SPRITES["blocks_test.png"].Load("assets/blocks_test.png"); |
|
|
|
|
|
|
|
|
|
std::random_device rd; //Will be used to obtain a seed for the random number engine
|
|
|
|
|
gen=std::mt19937(rd()); //Standard mersenne_twister_engine seeded with rd()
|
|
|
|
|
gen=std::mt19937(0); //Standard mersenne_twister_engine seeded with rd()
|
|
|
|
|
randBlockPos=std::uniform_int_distribution<>(0, 9); |
|
|
|
|
coinFlip=std::uniform_int_distribution<>(0, 1); |
|
|
|
|
|
|
|
|
@ -24,9 +25,9 @@ bool Meteos::OnUserCreate() |
|
|
|
|
bool Meteos::OnUserUpdate(float fElapsedTime) |
|
|
|
|
{ |
|
|
|
|
accumulatedTime+=fElapsedTime; |
|
|
|
|
while (accumulatedTime>=1/60.0f) { |
|
|
|
|
if (accumulatedTime>=1/60.0f) { |
|
|
|
|
updateGame(1/60.0f); |
|
|
|
|
accumulatedTime-=1/60.0f; |
|
|
|
|
accumulatedTime=0; |
|
|
|
|
} |
|
|
|
|
drawGame(); |
|
|
|
|
return true; |
|
|
|
@ -63,11 +64,16 @@ void Meteos::updateGame(float fElapsedTime){ |
|
|
|
|
yDiff-=snapYPos; |
|
|
|
|
c2.y+=yDiff; |
|
|
|
|
float influence=(float)c.getBlocks().size()/(c.getBlocks().size()+c2.getBlocks().size()); |
|
|
|
|
int blockCount=c.getBlocks().size(); |
|
|
|
|
//Copy every block from one clump to the other
|
|
|
|
|
for (int m=0;m<c2.getBlocks().size();m++) { |
|
|
|
|
Block&b4=c2.getBlocks()[m]; |
|
|
|
|
c.addBlock(b4.pos.x/12,(c2.getBlockPosition(b4).y-c.y)/12,b4.col); |
|
|
|
|
} |
|
|
|
|
if (blockCount+c2.getBlocks().size()!=c.getBlocks().size()) { |
|
|
|
|
std::cout<<"Block size is: "<<c.getBlocks().size()<<" but expected "<<blockCount+c2.getBlocks().size()<<std::endl; |
|
|
|
|
assert(false); |
|
|
|
|
} |
|
|
|
|
if (c.vspeed>0) { |
|
|
|
|
c.vspeed/=4; |
|
|
|
|
} |
|
|
|
@ -75,6 +81,7 @@ void Meteos::updateGame(float fElapsedTime){ |
|
|
|
|
c2.vspeed/=4; |
|
|
|
|
} |
|
|
|
|
c.vspeed=c.vspeed*influence+c2.vspeed*(1-influence); |
|
|
|
|
c.sortBlocks(); |
|
|
|
|
gameBoard.removeClump(j--); |
|
|
|
|
goto nextClumpCollisionCheck; |
|
|
|
|
} |
|
|
|
|