generated from sigonasr2/CPlusPlusProjectTemplate
Block Clump merging
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
9ada6ed0e0
commit
61354a8497
Binary file not shown.
10
main.cpp
10
main.cpp
@ -20,6 +20,7 @@ bool Meteos::OnUserCreate()
|
||||
|
||||
bool Meteos::OnUserUpdate(float fElapsedTime)
|
||||
{
|
||||
fElapsedTime=std::min(fElapsedTime,1/60.f);
|
||||
lastBlockSpawn+=fElapsedTime;
|
||||
if (lastBlockSpawn>=3.0f){
|
||||
lastBlockSpawn-=3.0f;
|
||||
@ -52,12 +53,19 @@ bool Meteos::OnUserUpdate(float fElapsedTime)
|
||||
float snapYPos=c.getBlockPosition(b3).y;
|
||||
yDiff-=snapYPos;
|
||||
c2.y+=yDiff;
|
||||
float influence=(float)c.getBlocks().size()/(c.getBlocks().size()+c2.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);
|
||||
}
|
||||
c.vspeed+=c2.vspeed;
|
||||
if (c.vspeed>0) {
|
||||
c.vspeed/=4;
|
||||
}
|
||||
if (c2.vspeed>0) {
|
||||
c2.vspeed/=4;
|
||||
}
|
||||
c.vspeed=c.vspeed*influence+c2.vspeed*(1-influence);
|
||||
gameBoard.removeClump(j--);
|
||||
goto nextClumpCollisionCheck;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user