diff --git a/objects/obj_chunk.object.gmx b/objects/obj_chunk.object.gmx
index 9d7ca99..e67fd99 100644
--- a/objects/obj_chunk.object.gmx
+++ b/objects/obj_chunk.object.gmx
@@ -7,7 +7,133 @@
0
<undefined>
<undefined>
-
+
+
+
+ 1
+ 603
+ 7
+ 0
+ 0
+ -1
+ 2
+
+
+ self
+ 0
+ 0
+
+
+ 1
+ /// GENERATE CHUNK
+var total_size = CHUNK_SIZE*TILE_SIZE;
+
+instance_list = array_create(total_size);
+cur_inst = 0;
+loaded = true;
+
+// GENERATION
+for(var xx = 0; xx < CHUNK_SIZE*TILE_SIZE; xx+= TILE_SIZE)
+{
+ for(var yy = 0; yy < CHUNK_SIZE*TILE_SIZE; yy+= TILE_SIZE)
+ {
+ if(random_range(0,100) > 50)
+ {
+ instance_list[cur_inst] = instance_create(x+xx,y+yy, obj_asteriod);
+ cur_inst ++;
+ }
+ }
+}
+
+
+
+
+
+
+
+ 1
+ 603
+ 7
+ 0
+ 0
+ -1
+ 2
+
+
+ self
+ 0
+ 0
+
+
+ 1
+ var chunk_total_size = CHUNK_SIZE * TILE_SIZE
+
+
+if(distance_to_object(obj_player) > chunk_total_size+(TILE_SIZE*5))
+{
+ event_user(0);
+}
+
+
+
+
+
+
+
+ 1
+ 603
+ 7
+ 0
+ 0
+ -1
+ 2
+
+
+ self
+ 0
+ 0
+
+
+ 1
+ for(var i = 0; i < cur_inst; i++)
+{
+ instance_activate_object(instance_list[i]);
+}
+loaded = true;
+
+
+
+
+
+
+
+ 1
+ 603
+ 7
+ 0
+ 0
+ -1
+ 2
+
+
+ self
+ 0
+ 0
+
+
+ 1
+ for(var i = 0; i < cur_inst; i++)
+{
+ instance_deactivate_object(instance_list[i]);
+}
+loaded = false;
+instance_deactivate_object(id);
+
+
+
+
+
+
0
0
0
diff --git a/objects/obj_controller_world_gen.object.gmx b/objects/obj_controller_world_gen.object.gmx
index 91219d4..b77bcf1 100644
--- a/objects/obj_controller_world_gen.object.gmx
+++ b/objects/obj_controller_world_gen.object.gmx
@@ -50,7 +50,9 @@
1
- var playX = obj_player.x;
+ /// Load / Unload Chunks
+
+var playX = obj_player.x;
var playY = obj_player.y;
var chunk_total_size = (CHUNK_SIZE*TILE_SIZE);
@@ -58,7 +60,6 @@ var chunk_total_size = (CHUNK_SIZE*TILE_SIZE);
var chunkRelX = playX % chunk_total_size;
var chunkRelY = playY % chunk_total_size;
-
var chunkX = (obj_player.x - chunkRelX);
var chunkY = (obj_player.y - chunkRelY);
@@ -83,10 +84,22 @@ if(chunkX == 0 && (playX < 0 && playX >= chunk_total_size/
}
-if(!place_meeting(chunkX, chunkY,obj_chunk))
+instance_activate_region(chunkX,chunkY,12,12,true);
+var chunkat = instance_position(chunkX, chunkY,obj_chunk);
+
+if(chunkat == noone) // create
{
+ show_debug_message("Generating chunk: "+string(chunkX)+","+string(chunkY));
instance_create(chunkX,chunkY,obj_chunk);
}
+else // load
+{
+ if(chunkat.loaded = false)
+ {
+ show_debug_message("Loading chunk: "+string(chunkX)+","+string(chunkY));
+ event_perform_object(chunkat,ev_user1,0);
+ }
+}
diff --git a/sprites/images/spr_chunk_0.png b/sprites/images/spr_chunk_0.png
index 82f0e79..a5bbd77 100644
Binary files a/sprites/images/spr_chunk_0.png and b/sprites/images/spr_chunk_0.png differ
diff --git a/sprites/spr_chunk.sprite.gmx b/sprites/spr_chunk.sprite.gmx
index 15ce81d..5f8e075 100644
--- a/sprites/spr_chunk.sprite.gmx
+++ b/sprites/spr_chunk.sprite.gmx
@@ -4,21 +4,21 @@
0
0
1
- 0
+ 255
0
1
0
- 511
+ 9
0
- 511
+ 9
0
0
0
0
- 512
- 512
+ 10
+ 10
images\spr_chunk_0.png