48 lines
1.1 KiB
Text
48 lines
1.1 KiB
Text
///load_chunk(cx,cy);
|
|
|
|
var cx = argument0
|
|
var cy = argument1
|
|
|
|
var chunk_grid = ds_grid_create(256,256);
|
|
var filename = string(cx)+","+string(cy)+".spr";
|
|
if(file_exists(filename)) // Load Chunk
|
|
{
|
|
ini_open(filename);
|
|
for(var xx = 0; xx < 256; xx++)
|
|
{
|
|
for(var yy = 0; yy < 256; yy++)
|
|
{
|
|
var nm = string(xx)+string(yy);
|
|
var c = ini_read_real("XYV",nm,0);
|
|
chunk_grid[xx,yy] = c;
|
|
if(c != 0)
|
|
instance_create(xx,yy,c);
|
|
}
|
|
}
|
|
ini_close();
|
|
}
|
|
else // Generate Chunk
|
|
{
|
|
ini_open(filename);
|
|
for(var xx = 0; xx < 256; xx++)
|
|
{
|
|
for(var yy = 0; yy < 256; yy++)
|
|
{
|
|
var nm = string(xx)+string(yy);
|
|
if(random_range(0,10) > 5)
|
|
{
|
|
ini_write_real("XYV",nm,obj_asteriod);
|
|
chunk_grid[xx,yy] = obj_asteriod;
|
|
instance_create(cx+xx,cy+yy,obj_asteriod);
|
|
}
|
|
else
|
|
{
|
|
ini_write_real("XYV",nm,0);;
|
|
chunk_grid[xx,yy] = 0;
|
|
}
|
|
}
|
|
}
|
|
ini_close();
|
|
}
|
|
return chunk_grid;
|
|
|