mp_grid_add_rectangle

This function asks you to define a rectangle within the room, and then it marks all MP grid cells "touch" that rectangle as being forbidden, meaning that the path-finding functions cannot cross them. The image below illustrates how this works:

Add rectangle exampleAs you can see, the rectangle defined by (50, 90) to (200, 180) marks all the equivalent MP grid cells that it touches as being forbidden.

 

Syntax:

mp_grid_add_rectangle(id, x1, y1, x2, y2);

ArgumentTypeDescription
idMP Grid IDIndex of the mp_grid that is to be used
x1RealThe x coordinate of the left side of the rectangle to check.
y1RealThe y coordinate of the top side of the rectangle to check.
x2RealThe x coordinate of the right side of the rectangle to check.
y2RealThe x coordinate of the bottom side of the rectangle to check.

 

Returns:

N/A

 

Example:

mp_grid_add_rectangle(grid, 0, 0, 100, 200);

The above code will mark as forbidden all cells of the mp_grid indexed in the variable "grid" that fall within the area 0,0 to 100,200.