title: How can i create a timer to count 10 seconds?
body: <p>My objective is when my powerball collides with the player’s ship it boosts the scrolling speed of the backgrounds and the speed of the enemy ships for 10seconds. I have came up with some code to do this but when I run the game and hit a powerball the background and enemy ships only speed up for a 2-3 seconds instead of 10.</p>
  
  <p>idk what I'm doing wrong so could anyone please help me out?
  this is what I have so far: </p>
  
  <pre><code>// Do the collision bewtween the player and the powerball
  for (int i = 0; i &lt; powerballs.Count; i++)
  {
      rectangle3 = new Rectangle((int)powerballs[i].Position.X,
          (int)powerballs[i].Position.Y,
          powerballs[i].Width,
          powerballs[i].Height);
  
      // Determine if the two objects collided with each other
      if (rectangle1.Intersects(rectangle3))
      {
          boost = true;
          powerballs[i].Active = false;
      }
      else
          boost = false;
  
      float elasped = (float)gameTime.ElapsedGameTime.TotalSeconds;
      timer -= elasped;
      if (boost == true &amp;&amp; timer &lt; 10f)
      {                   
              for (int j = 0; j &lt; enemies.Count; j++)
              {
                  // Increased enemy speed variable
                  float newEnemySpeed = 30f;
  
                  // Setting increased speed to each enemy in the list 
                  enemies[j].SetNewMoveSpeed(newEnemySpeed);
              }
              //Increased Background speed variables
              int newBackgroundSpeed1 = -5;
              int newBackgroundSpeed2 = -10;
  
              // Setting increased Background speed
              bgLayer1.SetNewSpeed(newBackgroundSpeed1);
              bgLayer2.SetNewSpeed(newBackgroundSpeed2);;
      }
      else
      {
          for (int k = 0; k &lt; enemies.Count; k++)
          {
              // Set emeny speed back to normal
              enemies[k].SetNewMoveSpeed(6f);
          }
          // Set background speed back to normal
          bgLayer1.SetNewSpeed(-1);
          bgLayer2.SetNewSpeed(-2);
      }
  }
  </code></pre>