A
AnimusRex
Guest
So I have a design room wherein I am scanning all my placeholder block objects, and saving them in a grid.
The code is as follows;
Then I'm trying to create objects based on the objects found in the design room, using the following code:
What am I doing wrong?
The code is as follows;
Code:
//Making design room invisible
if background_exists(bg_roomdesign)
{background_delete(bg_roomdesign)}
//Setting block size
blocksize = 32
var width = room_width div blocksize; //Number of columns
var height = room_height div blocksize; //Number of rows
// Creating the grid
blockgrid = ds_grid_create(width, height)
// Iterate through every cell in the grid
for (var i = 0; i < width; ++i)
{
for (var j = 0; j < height; ++j)
{
var translatedx = (i*blocksize)+(blocksize/2);
var translatedy = (j*blocksize)+(blocksize/2);
var thisobject = collision_point(translatedx, translatedy, all, false, false);
ds_grid_set(blockgrid, i, j, (thisobject));
}
}
Code:
for (var i = 0; i < width; ++i)
{
for (var j = 0; j < height; ++j)
{
if ds_grid_get(obj_arraycontroller.blockgrid,i,j)!= noone //As long as the grid value at i and j isn't zero
//Create an instance at i*blocksize, j*blocksize to convert it to the real gcoords
{
instance_create(i*blocksize, j*blocksize, obj_block1) //Call the object based on what was saved in the grid cell
}
}
}