title: C++ Monster Roaming Functionality
body: <p>I have a working monster system that follows players around by moving a certain distance towards the players 2D (X, Y) location.</p>
  
  <p>However, I now want to make it so these monsters roam around at random time intervals for a short distance. Say we have a monster that can travel anywhere from 200-300 cm/sec.</p>
  
  <p>I need to know how to accurately determine the monsters destination location (X, Y). Currently I simply pick a random number between 200-300 and then add those values to the monsters current X &amp; Y value. Although doing this will sometimes exceed the desired distance traveled.</p>
  
  <p>My question is, how can I pick a location on an X, Y grid that is a certain distance away from our current location.</p>
  
  <p>This is the moving code I have right now...</p>
  
  <pre><code>        // Determines if position is changed via addition or subtraction.
          const int positive_or_negative = RandomValueInRange_New(0, 1);
  
          // Determines how much to move in each direction
          const int x = RandomValueInRange(200, 300);
          const int y = RandomValueInRange(200, 300);
          if (positive_or_negative == 1)
          {
             location.Move(x, y);
          }
          else
          {
             location.Move(-x, -y);
          }
  </code></pre>