title: If conditional execution
body: <p>I have come across a situation I have not encountered before using the IF control structure, with a further nested IF. Normally the nested IF would break down what I am checking in more fine grained detail, but in this instance it actually conflicts with the outer conditional - I am checking for a mouse click.</p>
  
  <p>Here is the code -</p>
  
  <pre><code>if (mouseState.LeftButton == ButtonState.Pressed)
  {
       if (mouseState.LeftButton == ButtonState.Released)
       {
            //move sprite to clicked position
            spritePos.X = mouseState.X;
            spritePos.Y = mouseState.Y;
       }
  }
  </code></pre>
  
  <p>I have a couple of questions. I was taught that the conditional argument is only checked once, if it evaluates as true then the following statements are executed. <strong>Is this true</strong>, or is it actually checked before executing every statement within the block? - as the latter would obviously cause conflict with my nested if.</p>
  
  <p>If this is true, then why does my button click method not work? The sprite never moves as though the mouse release never executes. <strong>Is it because the delay</strong> between performing a check on both conditionals is so small, that I can not physically have released the button within that time? Can I be slightly hackish about this and <strong>overcome it with a time delay</strong> which might be large enough to allow the release of the mouse button by the time of checking the nested conditional?</p>
  
  <p>Methods for mouse click actions that I have seen, use properties of the mouse from the previous frame, and compare to the new frame to check for a mouse click. But this method must introduce a delay of at least one frame to actually process the action. This might not be noticeable with high framerates, but just for arguments sake say I had a game rendering 20fps. UpdateInput() would be called before rendering any frame, positions should update and then the frame should render last.</p>
  
  <p>If the full mouse click operation could operate within less than 1/20th of a second, wouldn't it be preferrable to process the action at once rather than store a variable upon the initial press, and compare states in the next frame? This would surely be better than introducing further delay on input.</p>
  
  <p>I'm sure this must have been considered by others before though, and perhaps I'm not thinking correctly about the time delay operation actually pausing execution of the code. <strong>Can time delays pause processor execution of code</strong>, or only the result of those executions such as rendering and accepting input? They are not something which I have any experience in using, and I may be confusing how a delay would work.</p>
  
  <p>Thank you,
  Andrew.</p>