Sets a cell in a grid to a given value.


GML Code Example

ds_grid_set(index, x, y, value);

Argument Description
index This index of the grid.
x The x position of the cell to set.
y The y position of the cell to set.
value The value with which to set the cell.

Returns: N/A


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:


GML Code Example

grid = ds_grid_create(5, 5);
 var i, j;
 i = 0;
 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.

No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here