ds_grid_set

Sets a cell in a grid to a given value.

Syntax:

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


Description

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:


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.


Back: DS Grids
Next: ds_grid_set_disk
© Copyright YoYo Games Ltd. 2018 All Rights Reserved