Returns the sum of all the cells within a region on a grid.


GML Code Example

ds_grid_get_sum(index, x1, y1, x2, y2);

Argument Description
index The index of the grid.
x1 The left cell column of the region.
y1 The top cell row of the region.
x2 The right cell column of the region.
y2 The bottom cell row of the region.

Returns: Real


This function can be used to add all the values all the cells found within the defined region of a grid together, as shown in the image below:


GML Code Example

val = ds_grid_get_sum(grid, 0, 0, 5, 5);

The above code will set the variable "val" to the sum of all values contained within the given region of the ds_grid indexed in the variable "grid".

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