CommitLog |

This commit is contained in:
SilicaAndPina 2020-07-24 08:57:47 +12:00
parent e74edd8841
commit a9c35b6d6c
9 changed files with 128 additions and 60 deletions

View file

@ -0,0 +1,20 @@
///generate_chunk()
var chunk_grid = ds_grid_create(128,128);
for(var xx = 0; xx < 128; xx++)
{
for(var yy = 0; yy < 128; yy++)
{
if(random_range(0,10) > 5)
{
chunk_grid = obj_asteriod;
}
else
{
chunk_grid = 0;
}
}
}

View file

@ -17,9 +17,7 @@ for(var xx = startx; xx < xmax; xx+=32)
{
for(var yy = starty; yy < ymax;yy+=32)
{
if(!place_free(xx,yy))
if(place_empty(xx,yy))
{
instance_create(xx,yy,obj_air);

48
scripts/load_chunk.gml Normal file
View file

@ -0,0 +1,48 @@
///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;