Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Used to manipulate pathfinding coordinates to constrain a position to within a rectangle.
- Positions are altered by shifting them back towards the inside edge of the rectangle.
- Returns the number of modifications done to the coordinates (0, 1 or 2)
- */
- ConstrainPositionToBox(&Float:x, &Float:y, Float:minx, Float:miny, Float:maxx, Float:maxy)
- {
- new modified;
- if(x < minx)
- {
- x = (minx + 1.0);
- modified++;
- }
- else if(x > maxx)
- {
- x = (maxx - 1.0);
- modified++;
- }
- if(y < miny)
- {
- y = (miny + 1.0);
- modified++;
- }
- else if(y > maxy)
- {
- y = (maxy - 1.0);
- modified++;
- }
- return modified;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement