W
whale_cancer
Guest
Hello!
I am trying to copy three (eventually five) small ds_grids read from an included file into a larger ds_grid. Through debugging, it seems as if the grids are being copied correctly? Or at least being referenced correctly? But when I use them to output the tile data they contain, they output tiles as if they were outputting background 0, with a top value of 0, and a left value of 0 (i.e. uninitialized ds_grid space).
My initial loading of the ds_grid data:
You can see I use loops to output all the tile data. That can be found here. I can confirm that those values correspond to the correct tile values (they are just random tiles I threw down from different tilesets in my map editor for testing purposes).
Here is the code for creating the actual tiles (remember, this outputs tiles that are all the same and correspond to background asset 0, top 0, and left 0 values):
The pastebin link also shows this debugging information as outputting 0, 0, 0.
Any idea what is going wrong? Any help greatly appreciated!
Edit: 0000.chunk file
It seems like after a week or so of good progress without needing help, I've started to run into problems again. Bah! Anyway, I think this is me probably just making some small error somewhere. Any help appreciated!
I am trying to copy three (eventually five) small ds_grids read from an included file into a larger ds_grid. Through debugging, it seems as if the grids are being copied correctly? Or at least being referenced correctly? But when I use them to output the tile data they contain, they output tiles as if they were outputting background 0, with a top value of 0, and a left value of 0 (i.e. uninitialized ds_grid space).
My initial loading of the ds_grid data:
Code:
//Create mega-data structures here
global.tile_bgmap = ds_grid_create(32 * 27, 32 * 27);
global.tile_left = ds_grid_create(32 * 27, 32 * 27);
global.tile_top = ds_grid_create(32 * 27, 32 * 27);
global.tile_collision = ds_grid_create(32 * 27, 32 * 27);
global.tile_vision = ds_grid_create(32 * 27, 32 * 27);
//Spawn the player
//<!-- change to spawn at a marker
//instance_create(1 * 512, 1 * 512, obj_player);
for (ww = 0; ww < 27; ww += 1)
{
for (hh = 0; hh < 27; hh += 1)
{
//an array that determines which chunks are loaded
//global.chunk_loaded[ww, hh] = false;
//load just the 0000 chunk for now
if (ww = 00) && (hh == 00)
{
//load the chunk
file = file_text_open_read('CHUNKS\0000.chunk')
//
temp_bg_grid = ds_grid_create(32, 32);
temp_left_grid = ds_grid_create(32, 32);
temp_top_grid = ds_grid_create(32, 32);
//GFX grids
temp_string = file_text_read_string(file);
ds_grid_read(temp_bg_grid, temp_string);
file_text_readln(file);
temp_string = file_text_read_string(file);
ds_grid_read(temp_left_grid, temp_string);
file_text_readln(file);
temp_string = file_text_read_string(file);
ds_grid_read(temp_top_grid, temp_string);
file_text_readln(file);
//debug
show_debug_message('---------------------------------------------------------------');
for (w = 0; w < 32; w += 1)
{
for (h = 0; h < 32; h += 1)
{
bg = ds_grid_get(temp_bg_grid, w, h);
left = ds_grid_get(temp_left_grid, w, h);
top = ds_grid_get(temp_top_grid, w, h);
show_debug_message('Temp grid value at '+string(w)+','+string(h)+' is '+background_get_name(bg)+' with left '+string(left)+' and top '+string(top))
}
}
show_debug_message('Copying chunk '+string(ww)+string(hh)+' to Worldspace grid.');
for (w = 0; w < 32; w += 1)
{
for (h = 0; h < 32; h += 1)
{
bg = ds_grid_get(temp_bg_grid, w, h);
left = ds_grid_get(temp_left_grid, w, h);
top = ds_grid_get(temp_top_grid, w, h);
ds_grid_set(global.tile_bgmap, w * ww, h * hh, bg)
ds_grid_set(global.tile_left, w * ww, h * hh, left)
ds_grid_set(global.tile_top, w * ww, h * hh, top)
show_debug_message('Setting grid at '+string(w*ww)+','+string(h*hh)+' to '+background_get_name(bg)+' '+string(left)+','+string(top))
}
}
//destroy temp grids
ds_grid_destroy(temp_bg_grid)
ds_grid_destroy(temp_left_grid)
ds_grid_destroy(temp_top_grid)
//close the file
file_text_close(file)
}
}
}
Here is the code for creating the actual tiles (remember, this outputs tiles that are all the same and correspond to background asset 0, top 0, and left 0 values):
Code:
for (ww = 0; ww < 27; ww += 1)
{
for (hh = 0; hh < 27; hh += 1)
{
//an array that determines which chunks are loaded
//global.chunk_loaded[ww, hh] = false;
//load just the starter cell
if (ww = 00) && (hh == 00)
{
//GFX information
for (w = 0; w < 32; w += 1)
{
for (h = 0; h < 32; h += 1)
{
bg = ds_grid_get(global.tile_bgmap, (ww * 32) + w, (hh * 32) + h);
left = ds_grid_get(global.tile_left, (ww * 32) + w, (hh * 32) + h);
top = ds_grid_get(global.tile_top, (ww * 32) + w, (hh * 32) + h);
show_debug_message('Placing tile at '+string(w*ww)+','+string(h*hh)+' to '+background_get_name(bg)+' '+string(left)+','+string(top))
tile_add(bg, left, top, 16, 16, (ww * 512) + (w * 16), (hh * 512) + (h * 16), 1000000);
}
}
}
}
}
Any idea what is going wrong? Any help greatly appreciated!
Edit: 0000.chunk file