title: While loop not working with bool statements in C (beginner!)
body: <p>I'm learning the basics right now and am making a simple game using a basic graphics library provided by my uni. </p>
  
  <ul>
  <li>There is a projectile thrown (the path of which is drawn)</li>
  <li>an obstacle (a wall) - which the projectile can't pass through so must go over</li>
  <li><p>and a target (must also appear solid so line stops being drawn when it is hit)</p></li>
  <li><p>Right now my projectile is being thrown right through the wall</p></li>
  <li><p>The issue is with the while loop</p></li>
  <li><p>Any conditions I add (after (y_displacement &lt; FLOOR_HEIGHT)) have had no effect</p></li>
  </ul>
  
  <p>(This projectile on its own stops drawing when y_displacement => FLOOR_HEIGHT (Y-Axis is inverted), but any addition of bool statements or attempts at using bool (after #including  too) to stop the projectile line being drawn don't make any changes.</p>
  
  <p>TRIED BOOL FOR WALL (doesn't change anything):</p>
  
  <pre><code>bool hit_wall = false;
  
  
          while ((y_displacement &lt; FLOOR_HEIGHT) &amp;&amp; (hit_wall == false))
          {
                  time = (x_displacement - X_HAND) / x_velocity; //speed = distance/time
                  y_displacement = (Y_HAND - y_velocity * time) - (GRAVITY * pow(time, 2)/2);
                  GFX_DrawLineTo(x_displacement, y_displacement, 3);
                  x_displacement += 1;
  
                  if ((x_displacement == (X_MAX/2.5)) &amp;&amp; ((y_displacement &gt; (Y_MAX/2))))
                     {
                         hit_wall = true;
                     }
          }
  </code></pre>
  
  <p>}</p>
  
  <p>If I can manage to sort this out then I should be able to do the same for my target..</p>
  
  <p>Is there something wrong with what I'm doing?</p>
  
  <p>BACKGROUND:</p>
  
  <p>The full function is this:</p>
  
  <pre><code>void throwBall(int(x_position), int(y_position))
  {
      GFX_SetColour(YELLOW);
  
      int x_mouse;
      int y_mouse;
  
      int x_distance;
      int y_distance;
  
      double angle;
  
      float initial_velocity;
  
      float x_velocity;
      float y_velocity;
  
      float time;
  
      GFX_MoveTo(X_HAND, Y_HAND);
  
      GFX_GetMouseCoordinates(&amp;x_mouse, &amp;y_mouse);
  
      x_distance = x_mouse - X_HAND;
      y_distance = y_mouse - Y_HAND;
  
      angle = getAngle(x_distance, y_distance);
  
      initial_velocity = sqrt(pow(x_distance, 2) + pow(y_distance, 2));
  
      //these have been divided by 5 as the magnitude was too large for the window
      y_velocity = (initial_velocity * sin (angle) - GRAVITY * time)/(X_MAX/256);
      x_velocity = (initial_velocity * cos (angle))/(X_MAX/256);
  
      float y_displacement;
      float x_displacement;
  
      x_displacement = X_HAND;
      y_displacement = Y_HAND;
  
  
      bool hit_wall = false;
  
  
              while ((y_displacement &lt; FLOOR_HEIGHT) &amp;&amp; (hit_wall == false))
              {
                      time = (x_displacement - X_HAND) / x_velocity; //speed = distance/time
                      y_displacement = (Y_HAND - y_velocity * time) - (GRAVITY * pow(time, 2)/2);
                      GFX_DrawLineTo(x_displacement, y_displacement, 3);
                      x_displacement += 1;
  
                      if ((x_displacement == (X_MAX/2.5)) &amp;&amp; ((y_displacement &gt; (Y_MAX/2))))
                         {
                             hit_wall = true;
                         }
              }
  }
  </code></pre>