title: code for a simple fighting game but after a player health becomes 0 game continues its loop
body: <p>so this is the entire code, it has a display function which does the displaying and processing of inputs and a main function which passes the display when the GameOver function is set to false</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;conio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;cstdlib&gt;
  #include &lt;ctime&gt;
  #define key_x 88
  using namespace std;
  bool GameOver = false;
  
  
  void Display() {
      int choose;
      char ch;
      system(&quot;color 04&quot;);
      cout &lt;&lt; &quot;WELCOME&quot; &lt;&lt; endl;
      for (int i = 1; i &lt; 5; i++) {
          cout &lt;&lt; &quot;Character &quot; &lt;&lt; i &lt;&lt; endl;
      }
      cout &lt;&lt; &quot;choose character number: &quot;;
      cin &gt;&gt; choose;
  
  
      if (choose &gt; 4) {
          cout &lt;&lt; &quot;Enter valid character number: &quot;;
          cin &gt;&gt; choose;
  
      }
      cout &lt;&lt; &quot;Selected Character is &quot; &lt;&lt; choose &lt;&lt; endl;
      system(&quot;pause&quot;);
      system(&quot;cls&quot;);
  
      srand((unsigned)time(0));
      int random = (rand() % 4) + 1;
      system(&quot;color 02&quot;);
      cout &lt;&lt; &quot;ENEMY IS CHARACTER &quot; &lt;&lt; random &lt;&lt; endl; 
  
       int hp1 = 100;
       int hp2 = 100;
  
      cout &lt;&lt; &quot;Character &quot; &lt;&lt; choose &lt;&lt; &quot;(&quot; &lt;&lt; hp1 &lt;&lt; &quot;)&quot; &lt;&lt; &quot; VS. Character &quot; &lt;&lt; random &lt;&lt; &quot;(&quot; &lt;&lt; hp2 &lt;&lt; &quot;)&quot; &lt;&lt; endl;
  
  
      while(!GameOver)                      
      {
          srand(time(0));
          int rand1 = (rand() % 100) + 1;
          int rand2 = (rand() % 100) + 1;
  
          int NewHp1 = hp1 - rand1;
          int NewHp2 = hp2 - rand2;
          
  
              cout &lt;&lt; &quot;Press any key to attack&quot; &lt;&lt; endl;
  
              ch = (_getch());
              int value = ch;
              while (value == key_x)
                  break;
  
              cout &lt;&lt; &quot;Enemy has &quot; &lt;&lt; NewHp2 &lt;&lt; &quot; health left.&quot; &lt;&lt; endl;
  
              system(&quot;pause&quot;);
  
              cout &lt;&lt; &quot;You have &quot; &lt;&lt; NewHp1 &lt;&lt; &quot; health left.&quot; &lt;&lt; endl;
  
              if (NewHp2 &lt;= 0) {
                  cout &lt;&lt; &quot;YOU WIN!!&quot; &lt;&lt; endl;
                  break;
                  GameOver = true;
              }
  
              else if (NewHp1 &lt;= 0) {
                  system(&quot;color 04&quot;);
                  cout &lt;&lt; &quot;YOU LOSE&quot; &lt;&lt; endl;
                  break;
                  GameOver = true;
              }
  
              else
              {
              
                  continue;
  
              }
      }
  
  }
  
  
  int main() {
      while(!GameOver)
            Display();
      
  }
  </code></pre>
  <p>after the hp goes below 0 the game just seems to continue taking the hp as 100 and restart, could anyone help me resolve this issue.
  I know this code is slightly messy, I have just started learning cpp</p>