M
Midastouch
Guest
Hello everyone,
I created a grid, each cell can have a value =0 or value = 1 (value 0 is water, value 1 is ground).
As you can see in the code bellow, i place randomly 50 obj_copper on the map, only on the cell with a value = 1
My problem is that it's very slow, it put 3-5 seconds to put my 50 obj_copper.
And in a while i will place more ad more objects.
I want to improve my code, can you help me?
I created a grid, each cell can have a value =0 or value = 1 (value 0 is water, value 1 is ground).
As you can see in the code bellow, i place randomly 50 obj_copper on the map, only on the cell with a value = 1
GML:
if instance_number(obj_copper) < 50 {
var aa, bb;
aa = irandom_range(0,ds_grid_width(grid_));
bb = irandom_range(0,ds_grid_height(grid_));
var value_copper = ds_grid_get(grid_, aa, bb);//check the value in the grid//check if value = 0 or 1
if (value_copper = 1) {
instance_create_depth(aa*32 ,bb*32,-1, obj_copper)
}}
And in a while i will place more ad more objects.
I want to improve my code, can you help me?