title: Why does it seem like operations are not being performed in the order of the code?
body: <p>Here's some background. I'm working on game similar to "Collapse." Blocks fill up at the bottom and when all twelve blocks have been filled they push up on to the playfield. I have a counter called (intNextSpawn) that not only tells when to "push up" the next row, as well as calculating vectors for the graphics. It resets to 0 when the blocks have been pushed up.</p>
  
  <p>I've added some debug text on the screen to try and see what is happening, but I can't seem to hunt down the issue. It almost seems like it is still incrementing the counter while trying to randomize the the block that's supposed to appear (things acting out of order). I end up getting "blank" blocks and it causes some really screwy effects while testing. It gets worse when jack up the speed.</p>
  
  <p>I'm willing to post any additional code that might help. Below are the two main blocks where this is could happening. Is there something I might be doing wrong or may there be a way I can prevent this from happening (if that's what it's doing)?</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p><em>Edit... The first code block is in the "Update" method</em></p>
  
  <pre><code>// Calculate time between spawning bricks
  float spawnTick = fltSpawnSpeed * fltSpawnSpeedModifier;
  
  fltSpawn += elapsed;
  
  if (fltSpawn &gt; spawnTick)
  {
      // Fetch a new random block.
      poNextLayer[intNextSpawn] = RandomSpawn();
      // Increment counter
      intNextSpawn++;
  
      // Max index reached
      if (intNextSpawn == 12)
      {
          // Push the line up. Returns true if lines go over the top.
          if (PushLine())
          {
              gmStateNew = GameState.GameOver;
              gmStateOld = GameState.Playing;
          }
  
          // Game still in play.
          else
          {
              // Reset spawn row to empty bricks.
              for (int i = 0; i &lt; 12; i++)
                  poNextLayer[i] = new PlayObject(ObjectType.Brick, PlayColor.Neutral, Vector2.Zero);
  
              intNextSpawn = 0;   // Reset spawn counter.
              intLines--;         // One less line to go...
           }
       }
  
       fltSpawn -= spawnTick;
  }
  </code></pre>
  
  <hr>
  
  <pre><code>private bool PushLine()
  {
      // Go through the playfield top down.
      for (int y = 14; y &gt;= 0; y--)
      {
          // and left to right
          for (int x = 0; x &lt; 12; x++)
          {
              // Top row contains an active block (GameOver)
              if ((y == 14) &amp;&amp; (poPlayField[x, y].Active))
                  // Stop here
                  return true;
              else
              {
                  // Not bottom row
                  if (y &gt; 0)
                  {
                      // Copy from block below
                      poPlayField[x, y] = poPlayField[x, y - 1];
                      // Move drawing position up 32px
                      poPlayField[x, y].MoveUp();
                  }
                  // Bottom row
                  else
                  {
                      // Copy from spawning row
                      poPlayField[x, y] = poNextLayer[x];
                      // Move drawing position up 32px (plus 4 more)
                      poPlayField[x, y].MoveUp(4);
                      // Make the block active (clickable)
                      poPlayField[x, y].Active = true;
                  }
              }
  
          }
      }
  
      // Game still in play.
      return false;
  }
  </code></pre>