title: While Loop Crash in C# game
body: <p>I am creating a Kinect Text Adventure game for a project. I know the code isn't that great, but the project features more on effects of the game than the game itself, so it doesn't have to be complicated. This section of code is used to progress through the game using certain skeletal positions. The problem I am having is that I am trying to use a while loop so that depending on the current value of f, it will go to that specific room. The only problem is when I use a while loop, it always crashes before it's even started. I'm not sure what the problem is</p>
  
  <pre><code>private void ProcessGesture(Joint head, Joint handleft, Joint handright)
      {
  
          while (f!=0)
          {
  
  
              if (handright.Position.Y &gt; head.Position.Y &amp;&amp; handleft.Position.Y &gt; head.Position.Y &amp;&amp; f == 1)
              {
                  txtBox1.Text = "You find yourself at the foot of a large mountain, with a gaping cave at the front. \nYou have come here to find the Lost Sword of Gaia and you have heard that it lies \nhere in the Cave of Borlak the Red. You can move east";
                  f = 2;
                  this.btnangle.Visibility = Visibility.Hidden;
                  this.slider1.Visibility = Visibility.Hidden;
                  this.Degree.Visibility = Visibility.Hidden;
                  this.helpbtn.Visibility = Visibility.Hidden;
  
  
              } 
  
              if (handright.Position.X &gt; 0.3 &amp;&amp; f == 2)
              {
                  txtBox1.Text = "You walk up to the entrance of the cave and spot and \nlittle goblin wearing a suit of armour and holding a spear. \n'I'm so bored' he says. 'What I need is a good high five'\nYou can go west";
                  f = 3;
                  this.sadGoblin.Visibility = Visibility.Visible;
              }
              if ((f == 3 &amp;&amp; handright.Position.Y &gt; head.Position.Y) || (f == 3 &amp;&amp; handleft.Position.Y &gt; head.Position.Y))
              {
                  Uri uri1 = new Uri("/SkeletalTracking;component/Resources/hgoblin.jpg", UriKind.Relative);
  
                  ImageSource source1 = new BitmapImage(uri1);
  
                  this.sadGoblin.Source = source1;
  
                  txtBox1.Text = "'Ah, thank you kind stranger, for that I shall let you in'.\n The goblin steps to the side ";
  
                  f = 4;
              }
              if (f == 4 &amp;&amp; handright.Position.Y &gt; head.Position.Y &amp;&amp; handleft.Position.Y &gt; head.Position.Y)
              {
                  this.sadGoblin.Visibility = Visibility.Hidden;
                  txtBox1.Text = "You are now in the main hall of the mountain. You can hear chanting and singing from the north.\nYou see a statue in the middle of the room and two doors to the left and right of it";
                  f = 5;
              }
              if (f == 5 &amp;&amp; handleft.Position.X &lt; -0.3)
              {
                  txtBox1.Text = "This is Borlak's treasure room. In here are all of the things he has colleted over the years\nSome bought and some not so bought.\nYour eyes are drawn to a necklace in a glass case in the center of the room.\nThere is also a picture of Borlak holding a giant chunk of ham\nYou can go east";
                  f = 6;
  
              }
              if (f == 6 &amp;&amp; handright.Position.X &gt; 0.3)
              {
                  f = 5;
              }
              //else if (f == 5 &amp;&amp; handright.Position.X &gt; 0.3)
              // {
              //     txtBox1.Text = "";
              // }
  
  
  
  
          }
  
  
  
      }
  </code></pre>