19.3.3 addPoints

This last feature will add points to the score. At that time we will also check whether the next level is reached and if so, adjust the speed. We will also check if the player has won the game, because this is the only moment when such can happen.

Again, add the code below to your application. Make sure you understand all of it. Just typing is not enough!

 
void addPoints(int value) 
{ 
  if(value > 0) 
  { 
5    points += POINTS_PER_LINE * value; 
    SoundManager.score(); 
 
    if(points >= level * POINTS_PER_LEVEL) 
    { 
10      level++; 
      checkWin(); 
      speed -= SPEED_CHANGE; 
    } 
  } 
15}