@ -37,6 +37,7 @@ bool Meteos::OnUserUpdate(float fElapsedTime)
accumulatedTime + = fElapsedTime ;
if ( accumulatedTime > = 1 / 60.0f ) {
updateGame ( 1 / 60.0f ) ;
frameTime + + ;
accumulatedTime = 0 ;
}
handleInput ( ) ;
@ -506,6 +507,8 @@ void Meteos::matchFlyingBlockClumps(){
c . vspeed = gameBoard . launchSpd [ std : : min ( c . combo , ( int ) gameBoard . launchSpd . size ( ) - 1 ) ] / ( 1 + ( c . getBlocks ( ) . size ( ) * gameBoard . blockWeight ) ) ;
c . launchTime = gameBoard . launchTime ;
c . combo + + ;
score + = MATCH_SCORE * c . combo ;
displayTargetScore + = MATCH_SCORE * c . combo ;
vi2d randomOffset = { comboOverlayOffset ( gen ) , comboOverlayOffset ( gen ) } ;
comboDisplayList . push_back ( { c . getBlockPosition ( gameBoard . getBlockClumps ( ) [ matchedBlockIDs [ 0 ] . c ] . getBlocks ( ) [ matchedBlockIDs [ 0 ] . ind ] ) + randomOffset , c . combo } ) ;
//std::cout<<"Combo value is "<<c.combo<<std::endl;
@ -770,6 +773,8 @@ void Meteos::matchGroundedBlocks(){
gameBoard . getBlockClumps ( ) [ gameBoard . getBlockClumps ( ) . size ( ) - 1 ] . vspeed = gameBoard . launchSpd [ std : : min ( gameBoard . getBlockClumps ( ) [ gameBoard . getBlockClumps ( ) . size ( ) - 1 ] . combo , ( int ) gameBoard . launchSpd . size ( ) - 1 ) ] / ( 1 + ( gameBoard . getBlockClumps ( ) [ gameBoard . getBlockClumps ( ) . size ( ) - 1 ] . getBlocks ( ) . size ( ) * gameBoard . blockWeight ) ) ;
gameBoard . getBlockClumps ( ) [ gameBoard . getBlockClumps ( ) . size ( ) - 1 ] . launchTime = gameBoard . launchTime ;
gameBoard . getBlockClumps ( ) [ gameBoard . getBlockClumps ( ) . size ( ) - 1 ] . combo + + ;
score + = MATCH_SCORE * gameBoard . getBlockClumps ( ) [ gameBoard . getBlockClumps ( ) . size ( ) - 1 ] . combo ;
displayTargetScore + = MATCH_SCORE * gameBoard . getBlockClumps ( ) [ gameBoard . getBlockClumps ( ) . size ( ) - 1 ] . combo ;
vi2d randomOffset = { comboOverlayOffset ( gen ) , comboOverlayOffset ( gen ) } ;
comboDisplayList . push_back ( { baseBlockPos + randomOffset , gameBoard . getBlockClumps ( ) [ gameBoard . getBlockClumps ( ) . size ( ) - 1 ] . combo } ) ;
//std::cout<<"Combo value is "<<gameBoard.getBlockClumps()[gameBoard.getBlockClumps().size()-1].combo<<std::endl;
@ -789,6 +794,16 @@ void Meteos::cleanupBlocks(){
Block & b = c . getBlocks ( ) [ j ] ;
b . addedToLaunchList = false ;
if ( c . vspeed < 0 & & c . getBlockPosition ( b ) . y < 0 | | b . markedForRemoval ) {
if ( c . vspeed < 0 & & c . getBlockPosition ( b ) . y < 0 ) {
accumulatedScore + = BASE_SCORE * c . combo ;
score + = BASE_SCORE * c . combo ;
blocksInAttackQueue + + ;
lastBlockLaunched = 0.0f ;
if ( blocksInAttackQueue % 10 = = 0 ) {
accumulatedScore + = BONUS_ATTACK_SCORE ;
score + = BONUS_ATTACK_SCORE ;
}
}
std : : cout < < " Removed block @ " < < b . pos < < " from clump " < < i < < std : : endl ;
c . removeBlock ( j ) ;
}
@ -874,6 +889,50 @@ void Meteos::updateGame(float fElapsedTime){
handleWarningLevels ( fElapsedTime ) ;
validateSelectedBlock ( ) ;
handleComboAnimations ( ) ;
if ( blocksInAttackQueue ) {
lastBlockLaunched + = fElapsedTime ;
if ( lastBlockLaunched > = blockLaunchWaitPeriod ) {
blocksInAttackQueue = 0 ;
accumulatedScore = 0 ;
displayTargetScore = score ;
}
}
lastScoreDisplayUpdate + = fElapsedTime ;
if ( lastScoreDisplayUpdate > = SCORE_DISPLAY_UPDATE_RATE ) {
if ( displayScore ! = displayTargetScore ) {
int tempScore = displayTargetScore ;
int tempDisplayScore = displayScore ;
std : : vector < int > targetScoreDigits ;
std : : vector < int > displayScoreDigits ;
while ( tempScore > 0 ) {
int digit = tempScore % 10 ;
tempScore / = 10 ;
targetScoreDigits . insert ( targetScoreDigits . begin ( ) , digit ) ;
std : : cout < < digit ;
}
while ( tempDisplayScore > 0 ) {
int digit = tempDisplayScore % 10 ;
tempDisplayScore / = 10 ;
displayScoreDigits . insert ( displayScoreDigits . begin ( ) , digit ) ;
std : : cout < < digit ;
}
std : : cout < < std : : endl ;
int marker = 0 ;
while ( marker < targetScoreDigits . size ( ) | | marker < displayScoreDigits . size ( ) ) {
int targetScoreDigit = marker < targetScoreDigits . size ( ) ? targetScoreDigits [ targetScoreDigits . size ( ) - 1 - marker ] : 0 ;
int displayScoreDigit = marker < displayScoreDigits . size ( ) ? displayScoreDigits [ displayScoreDigits . size ( ) - 1 - marker ] : 0 ;
if ( displayScoreDigit ! = targetScoreDigit ) {
if ( displayScoreDigit + 1 < 10 ) {
displayScore + = std : : pow ( 10 , marker ) ;
} else {
displayScore - = std : : pow ( 10 , marker ) * 9 ;
}
}
marker + + ;
}
}
lastScoreDisplayUpdate = 0 ;
}
}
void Meteos : : drawGame ( float fElapsedTime , bool debugView ) {
@ -911,6 +970,13 @@ void Meteos::drawGame(float fElapsedTime,bool debugView){
DrawStringPropDecal ( c . pos + gameBoard . drawOffset + shadowOffset , " x " + std : : to_string ( c . combo ) , BLACK , { 0.8 , 0.6 } ) ;
DrawStringPropDecal ( c . pos + gameBoard . drawOffset , " x " + std : : to_string ( c . combo ) , ( c . lifetime % 6 > = 3 ) ? Pixel { 207 , 103 , 0 } : Pixel { 255 , 255 , 255 , 180 } , { 0.8 , 0.6 } ) ;
}
DrawStringDecal ( gameBoard . drawOffset + vi2d { - 8 , - 16 } + vi2d { 1 , 1 } , std : : to_string ( displayScore ) , BLACK , { 2 , 2 } ) ;
DrawStringDecal ( gameBoard . drawOffset + vi2d { - 8 , - 16 } , std : : to_string ( displayScore ) , WHITE , { 2 , 2 } ) ;
if ( accumulatedScore > 0 ) {
DrawStringDecal ( gameBoard . drawOffset + vi2d { 0 , 0 } + vi2d { 1 , 1 } , " + " + std : : to_string ( accumulatedScore ) , BLACK , { 0.75 , 0.75 } ) ;
DrawStringDecal ( gameBoard . drawOffset + vi2d { 0 , 0 } , " + " + std : : to_string ( accumulatedScore ) , frameTime % 5 > 2 ? Pixel { 224 , 184 , 148 } : WHITE , { 0.75 , 0.75 } ) ;
}
}
int main ( )