title: XNA simple state machine doesn't do anything
body: <p>I'm working on a project for my Video Game Design class where I basically had to find some bugs in some code, fix it, and then convert it all into a state machine using an enumeration. I've pasted the initialize, update, and draw methods below, and as you can see, I've commented out the old code before converting it into a state machine. Everything was working fine before with all the if/else statements, but now that I've converted it, it doesn't actually do anything. It displays the standing sprite in the starting position, but pressing the keys does absolutely nothing.</p>
  
  <p>INSTANTIATING VARIABLES</p>
  
  <pre><code>    Texture2D heroineTexture, dive, duck, jump, stand;
      int yVelocity, jumpVelocity, diveVelocity;
      Rectangle player;
      enum State
      {
          Standing,
          Jumping,
          Ducking,
          Diving
      };
      State state;
  
      KeyboardState kb, oldkb;
  </code></pre>
  
  <p>INITIALIZE</p>
  
  <pre><code>        oldkb = Keyboard.GetState();
          jumpVelocity = -10;
          diveVelocity = 15;
          yVelocity = 0;
          heroineTexture = stand;
          state = State.Standing;
          player = new Rectangle(0, 430, 50, 40);
          base.Initialize();
  </code></pre>
  
  <p>UPDATE</p>
  
  <pre><code>        kb = Keyboard.GetState();
          // Allows the game to exit
          if (kb.IsKeyDown(Keys.Escape))
              this.Exit();
  
          // TODO: Add your update logic here
  
          player.Y += yVelocity;
  
          switch (state)
          {
              case State.Standing:
                  if (kb.IsKeyDown(Keys.J))
                  {
                      state = State.Jumping;
                      yVelocity = jumpVelocity;
                      heroineTexture = jump;
                  }
                  else if (kb.IsKeyDown(Keys.Down))
                  {
                      state = State.Ducking;
                      heroineTexture = duck;
                  }
                  break;
              case State.Jumping:
                  if (kb.IsKeyDown(Keys.Down))
                  {
                      state = State.Diving;
                      heroineTexture = dive;
                      yVelocity = diveVelocity;
                  }
                  break;
              case State.Ducking:
                  if (!kb.IsKeyDown(Keys.Down))
                  {
                      state = State.Standing;
                      heroineTexture = stand;
                  }
                  break;
          }
  
  
          if (player.Y &gt;= 430)
          {
              state = State.Standing;
              player.Y = 430;
              yVelocity = 0;
              heroineTexture = stand;
          }
  
          //if (kb.IsKeyDown(Keys.J) &amp;&amp; oldkb.IsKeyUp(Keys.J))
          //{
          //    if (!isJumping &amp;&amp; !isDucking)
          //    {
          //        isJumping = true;
          //        yVelocity = jumpVelocity;
          //        heroineTexture = jump;
          //    }
          //}
          //else if(kb.IsKeyDown(Keys.Down))
          //{
          //    if(!isJumping)
          //    {
          //        if(isDiving)
          //        {
          //            yVelocity = diveVelocity;
          //        }
          //        else if(!isJumping &amp;&amp; !isDiving)
          //        {
          //            isDucking = true;
          //            heroineTexture = duck;
          //        }
          //    }
          //    else
          //    {
          //        isJumping = false;
          //        heroineTexture = dive;
          //        isDiving = true;
          //    }
          //}
          //else if(!kb.IsKeyDown(Keys.Down))
          //{
          //    if(isDucking)
          //    {
          //        isDucking = false;
          //        heroineTexture = stand;
          //    }
          //}
  
          oldkb = kb;
          base.Update(gameTime);
  </code></pre>