This function can be used to set a given cell within the given DS grid to any value, which can be a real number or a string. The image below illustrates this:
ds_grid_set(index, x, y, value);
Argument | Type | Description |
---|---|---|
index | DS Grid | This index of the grid. |
x | Real | The x position of the cell to set. |
y | Real | The y position of the cell to set. |
value | Any | The value with which to set the cell. |
N/A
grid = ds_grid_create(5, 5);
var i = 0;
var j = 0;
repeat (ds_grid_width(grid))
{
repeat (ds_grid_height(grid))
{
ds_grid_set(grid, i, j, irandom(9));
j += 1;
}
j = 0;
i += 1;
}
The above code creates a grid and stores its index in the variable "grid". It then populates this grid with random integers from 0 to 9.