From 80607ec47ce204241ad4deaaf194ce946aef855d Mon Sep 17 00:00:00 2001 From: SilicaAndPina Date: Thu, 23 Jul 2020 12:01:43 +1200 Subject: [PATCH] CommitLog | --- objects/obj_controller_world_gen.object.gmx | 39 ++++++++++++++++++++- objects/obj_player.object.gmx | 1 - scripts/generate_world.gml | 25 ++++++------- 3 files changed, 51 insertions(+), 14 deletions(-) diff --git a/objects/obj_controller_world_gen.object.gmx b/objects/obj_controller_world_gen.object.gmx index bbd79d6..5f72b4e 100644 --- a/objects/obj_controller_world_gen.object.gmx +++ b/objects/obj_controller_world_gen.object.gmx @@ -26,8 +26,45 @@ 1 generated_count = 0; -generated_areas = array_create(1000); +generated_areas[10000] = 0; +///Generate World + + +var startx = view_xview[0]; +var starty = view_yview[0] +var xmax = startx + view_wview[0]; +var ymax = starty + view_hview[0]; + +xmax = xmax - (xmax % 32); +ymax = ymax - (ymax % 32); + +startx = startx - (startx % 32); +starty = starty - (starty % 32); + + + + + + + + + 1 + 603 + 7 + 0 + 0 + -1 + 2 + + + self + 0 + 0 + + + 1 + generate_world(); diff --git a/objects/obj_player.object.gmx b/objects/obj_player.object.gmx index 74a85e2..f53a863 100644 --- a/objects/obj_player.object.gmx +++ b/objects/obj_player.object.gmx @@ -83,7 +83,6 @@ view_yview[0] = y - view_hview[0]/2; direction = image_angle speed += 5 -generate_world(); diff --git a/scripts/generate_world.gml b/scripts/generate_world.gml index 68f0a47..5148205 100644 --- a/scripts/generate_world.gml +++ b/scripts/generate_world.gml @@ -1,23 +1,24 @@ -///Generate World Chunks -var xmax = view_xview[0] + view_wview[0]; -var ymax = view_yview[0] - view_hview[0]; - -show_debug_message(xmax); -show_debug_message(ymax); - -for(var xx = view_xview[0]; xx < xmax;xx+=32) +for(var xx = startx; xx < xmax;xx+=32) { - for(var yy = view_yview[0]; yy < ymax;yy+=32) - { var expe = string(xx)+string(yy) - for(var i = 0; i <= obj_controller_world_gen.generated_count; i++) + for(var yy = starty; yy < ymax;yy+=32) + { + var expe = string(xx)+string(yy) + var should_continue = false; + for(var i = 0; i <= count; i++) { if(obj_controller_world_gen.generated_areas[i] == expe) { - return 0; + should_continue = true; + break; } } + if(should_continue) + { + continue; + } + obj_controller_world_gen.generated_areas[obj_controller_world_gen.generated_count] = expe; obj_controller_world_gen.generated_count ++;