CommitLog |
This commit is contained in:
parent
c964df8a67
commit
d0a28aa811
4 changed files with 148 additions and 9 deletions
|
@ -7,7 +7,133 @@
|
|||
<persistent>0</persistent>
|
||||
<parentName><undefined></parentName>
|
||||
<maskName><undefined></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 < 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 ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
</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) > 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 < 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 < cur_inst; i++)
|
||||
{
|
||||
instance_deactivate_object(instance_list[i]);
|
||||
}
|
||||
loaded = false;
|
||||
instance_deactivate_object(id);
|
||||
</string>
|
||||
</argument>
|
||||
</arguments>
|
||||
</action>
|
||||
</event>
|
||||
</events>
|
||||
<PhysicsObject>0</PhysicsObject>
|
||||
<PhysicsObjectSensor>0</PhysicsObjectSensor>
|
||||
<PhysicsObjectShape>0</PhysicsObjectShape>
|
||||
|
|
|
@ -50,7 +50,9 @@
|
|||
<arguments>
|
||||
<argument>
|
||||
<kind>1</kind>
|
||||
<string>var playX = obj_player.x;
|
||||
<string> /// 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);
|
||||
}
|
||||
}
|
||||
</string>
|
||||
</argument>
|
||||
</arguments>
|
||||
|
|
Reference in a new issue