Clears the indicated cell of an mp_grid.


mp_grid_clear_cell(id, h, v);

Argument Description
id Index of the mp_grid that is to be used
h Horizontal position of the cell to clear
v vertical position of the cell to clear

Returns: Boolean.


This function can be used to clear a specific "cell" of an mp_grid. Cells are not calculated as room coordinates, but rather as grid coordinates, where (0,0) is the top let corner of the grid. this means that to clear a cell at a specific position in the room, we must change the x and y coordinates into cell coordinate dividing them by the resolution of the mp_grid. The code example below shows how this works.


with (obj_Box)
   mp_grid_clear_cell(grid, floor(x / 32), floor(y /32));

The above code will make all "obj_Box" destroy themselves and have them mark the cells they occupied in the mp_grid indexed in the variable "grid" as free. In this example, we find the appropriate cell by taking the x/y coordinate of the object and dividing them by the resolution of the grid (using floor to keep the values as integers);

Back: Motion Planning
Next: mp_grid_clear_rectangle
© Copyright YoYo Games Ltd. 2015 All Rights Reserved