/// @func instance_create_random_grid(width, height, density, deviance, instance)
/// @arg0 width width of area
/// @arg1 height height of area
/// @arg2 density the higher the value the greater the density of the distribution
/// @arg3 deviance randomness factor within cell
/// @arg4 instance
var w = argument0; // Width of grid
var h = argument1; // Height of grid
var d = argument2; // Density of elements (size of cell)
var r = argument3; // Random deviation within cell
var i = argument4; // Instance to create
var gridw = w / d; // How many cells to create on the x-axis
var gridh = h / d; // How many cells to create on the y-axis
for (var xx = 0; xx < gridw; xx++) {
for (var yy = 0; yy < gridh; yy++) {
var cell_posx = d * xx + d / 2; // x-position of cell within grid (centred)
var cell_posy = d * yy + d / 2; // y-position of cell within grid (centred)
var cell_disx = d * random_range(-r, r); // x-position within cell
var cell_disy = d * random_range(-r, r); // y-position within cell
instance_create_layer(
x + cell_posx + cell_disx,
y + cell_posy + cell_disy,
"Instances", i)
}
}
Comments
0 B
|👍
/👎
0 B
|👍
/👎