Advertisement
Guest User

Untitled

a guest
Apr 1st, 2015
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. Vector2 WaveGen::RandomiseSafePosition(Vector2 target_, float safetyDistance_)
  2. {
  3.    
  4.     //randomise a position
  5.     int xPos = rand() % 100;
  6.     int yPos = rand() % 100;
  7.     Vector2 pos = Vector2(xPos,yPos);
  8.  
  9.     //check pos against the target_ pos
  10.     float distance = (target_ - pos).GetMagnitude();
  11.     if ( distance < safetyDistance_ )
  12.         return RandomiseSafePosition(target_, safetyDistance_); //try again
  13.  
  14.     return pos;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement