CommitLog |

This commit is contained in:
SilicaAndPina 2020-07-24 15:08:32 +12:00
parent c964df8a67
commit d0a28aa811
4 changed files with 148 additions and 9 deletions

View file

@ -7,7 +7,133 @@
<persistent>0</persistent> <persistent>0</persistent>
<parentName>&lt;undefined&gt;</parentName> <parentName>&lt;undefined&gt;</parentName>
<maskName>&lt;undefined&gt;</maskName> <maskName>&lt;undefined&gt;</maskName>
<events/> <events>
<event eventtype="0" enumb="0">
<action>
<libid>1</libid>
<id>603</id>
<kind>7</kind>
<userelative>0</userelative>
<isquestion>0</isquestion>
<useapplyto>-1</useapplyto>
<exetype>2</exetype>
<functionname></functionname>
<codestring></codestring>
<whoName>self</whoName>
<relative>0</relative>
<isnot>0</isnot>
<arguments>
<argument>
<kind>1</kind>
<string>/// 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 &lt; CHUNK_SIZE*TILE_SIZE; xx+= TILE_SIZE)
{
for(var yy = 0; yy &lt; CHUNK_SIZE*TILE_SIZE; yy+= TILE_SIZE)
{
if(random_range(0,100) &gt; 50)
{
instance_list[cur_inst] = instance_create(x+xx,y+yy, obj_asteriod);
cur_inst ++;
}
}
}
</string>
</argument>
</arguments>
</action>
</event>
<event eventtype="3" enumb="0">
<action>
<libid>1</libid>
<id>603</id>
<kind>7</kind>
<userelative>0</userelative>
<isquestion>0</isquestion>
<useapplyto>-1</useapplyto>
<exetype>2</exetype>
<functionname></functionname>
<codestring></codestring>
<whoName>self</whoName>
<relative>0</relative>
<isnot>0</isnot>
<arguments>
<argument>
<kind>1</kind>
<string>var chunk_total_size = CHUNK_SIZE * TILE_SIZE
if(distance_to_object(obj_player) &gt; chunk_total_size+(TILE_SIZE*5))
{
event_user(0);
}
</string>
</argument>
</arguments>
</action>
</event>
<event eventtype="7" enumb="11">
<action>
<libid>1</libid>
<id>603</id>
<kind>7</kind>
<userelative>0</userelative>
<isquestion>0</isquestion>
<useapplyto>-1</useapplyto>
<exetype>2</exetype>
<functionname></functionname>
<codestring></codestring>
<whoName>self</whoName>
<relative>0</relative>
<isnot>0</isnot>
<arguments>
<argument>
<kind>1</kind>
<string>for(var i = 0; i &lt; cur_inst; i++)
{
instance_activate_object(instance_list[i]);
}
loaded = true;
</string>
</argument>
</arguments>
</action>
</event>
<event eventtype="7" enumb="10">
<action>
<libid>1</libid>
<id>603</id>
<kind>7</kind>
<userelative>0</userelative>
<isquestion>0</isquestion>
<useapplyto>-1</useapplyto>
<exetype>2</exetype>
<functionname></functionname>
<codestring></codestring>
<whoName>self</whoName>
<relative>0</relative>
<isnot>0</isnot>
<arguments>
<argument>
<kind>1</kind>
<string>for(var i = 0; i &lt; cur_inst; i++)
{
instance_deactivate_object(instance_list[i]);
}
loaded = false;
instance_deactivate_object(id);
</string>
</argument>
</arguments>
</action>
</event>
</events>
<PhysicsObject>0</PhysicsObject> <PhysicsObject>0</PhysicsObject>
<PhysicsObjectSensor>0</PhysicsObjectSensor> <PhysicsObjectSensor>0</PhysicsObjectSensor>
<PhysicsObjectShape>0</PhysicsObjectShape> <PhysicsObjectShape>0</PhysicsObjectShape>

View file

@ -50,7 +50,9 @@
<arguments> <arguments>
<argument> <argument>
<kind>1</kind> <kind>1</kind>
<string>var playX = obj_player.x; <string> /// Load / Unload Chunks
var playX = obj_player.x;
var playY = obj_player.y; var playY = obj_player.y;
var chunk_total_size = (CHUNK_SIZE*TILE_SIZE); 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 chunkRelX = playX % chunk_total_size;
var chunkRelY = playY % chunk_total_size; var chunkRelY = playY % chunk_total_size;
var chunkX = (obj_player.x - chunkRelX); var chunkX = (obj_player.x - chunkRelX);
var chunkY = (obj_player.y - chunkRelY); var chunkY = (obj_player.y - chunkRelY);
@ -83,10 +84,22 @@ if(chunkX == 0 &amp;&amp; (playX &lt; 0 &amp;&amp; playX &gt;= 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); 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);
}
}
</string> </string>
</argument> </argument>
</arguments> </arguments>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 76 B

View file

@ -4,21 +4,21 @@
<xorig>0</xorig> <xorig>0</xorig>
<yorigin>0</yorigin> <yorigin>0</yorigin>
<colkind>1</colkind> <colkind>1</colkind>
<coltolerance>0</coltolerance> <coltolerance>255</coltolerance>
<sepmasks>0</sepmasks> <sepmasks>0</sepmasks>
<bboxmode>1</bboxmode> <bboxmode>1</bboxmode>
<bbox_left>0</bbox_left> <bbox_left>0</bbox_left>
<bbox_right>511</bbox_right> <bbox_right>9</bbox_right>
<bbox_top>0</bbox_top> <bbox_top>0</bbox_top>
<bbox_bottom>511</bbox_bottom> <bbox_bottom>9</bbox_bottom>
<HTile>0</HTile> <HTile>0</HTile>
<VTile>0</VTile> <VTile>0</VTile>
<TextureGroups> <TextureGroups>
<TextureGroup0>0</TextureGroup0> <TextureGroup0>0</TextureGroup0>
</TextureGroups> </TextureGroups>
<For3D>0</For3D> <For3D>0</For3D>
<width>512</width> <width>10</width>
<height>512</height> <height>10</height>
<frames> <frames>
<frame index="0">images\spr_chunk_0.png</frame> <frame index="0">images\spr_chunk_0.png</frame>
</frames> </frames>