spr_chunk
0
-1
0
0
<undefined>
<undefined>
1
603
7
0
0
-1
2
self
0
0
1
/// GENERATE CHUNK
instance_list = ds_list_create();
loaded = true;
var hasGeneratedBlackHole = false;
var hasGeneratedBrokenShip = false;
// 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)
{
var rnd = random_range(0,10000);
if(floor(rnd % 10000) == 8103)
{
if(hasGeneratedBrokenShip)
continue;
var inst = instance_create(x+xx,y+yy, obj_broken_ship);
inst.CHUNK_CONTAINED = self.id;
ds_list_add(instance_list, inst);
hasGeneratedBrokenShip = true;
continue;
}
if(floor(rnd % 5000) == 1000)
{
if(hasGeneratedBlackHole)
continue;
var inst = instance_create(x+xx,y+yy, obj_black_hole);
inst.CHUNK_CONTAINED = self.id;
ds_list_add(instance_list, inst);
hasGeneratedBlackHole = true;
continue;
}
if(rnd % 100 < 1)
{
var inst = instance_create(x+xx,y+yy, obj_asteriod);
inst.CHUNK_CONTAINED = self.id;
ds_list_add(instance_list, inst);
continue;
}
}
}
1
603
7
0
0
-1
2
self
0
0
1
///Place blocks
if(mouse_check_button_pressed(mb_right) || gamepad_button_check_pressed(0,gp_shoulderl))
{
if(obj_inv_controller.is_open)
{
return 0;
}
var selected_item = obj_inv_controller.inventory[obj_hotbar.selected_slot];
if(selected_item != 0)
{
var selX = round(mouse_x/TILE_SIZE)*TILE_SIZE;
var selY = round(mouse_y/TILE_SIZE)*TILE_SIZE;
selX -= TILE_SIZE / 2;
selY -= TILE_SIZE / 2;
var objid = instance_position(selX,selY,obj_placed_item)
if(objid != noone)
{
show_debug_message(string(objid)+", "+string(objid.object_index));
return 0;
}
objid = instance_position(selX,selY,obj_player)
if(objid != noone)
{
show_debug_message(string(objid)+", "+string(objid.object_index));
return 0;
}
var inst = instance_create(selX,selY,obj_placed_item);
use_item_in_inventory(obj_hotbar.selected_slot);
var chunkid = id;
with(inst){
inst.ITEM_ID = selected_item;
inst.CHUNK_CONTAINED = chunkid;
}
ds_list_add(instance_list, 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*3)
{
event_user(0);
}
1
603
7
0
0
-1
2
self
0
0
1
/// load
for(var i = 0; i < ds_list_size(instance_list); i++)
{
instance_activate_object(instance_list[| i]);
}
loaded = true;
1
603
7
0
0
-1
2
self
0
0
1
/// unload
for(var i = 0; i < ds_list_size(instance_list); i++)
{
instance_deactivate_object(instance_list[| i]);
}
loaded = false;
instance_deactivate_object(id);
1
603
7
0
0
-1
2
self
0
0
1
if(global.debug)
draw_self();
var selX = round(mouse_x/TILE_SIZE)*TILE_SIZE;
var selY = round(mouse_y/TILE_SIZE)*TILE_SIZE;
selX -= TILE_SIZE / 2;
selY -= TILE_SIZE / 2;
draw_set_color(c_white);
draw_rectangle(selX,selY,selX + TILE_SIZE, selY + TILE_SIZE, true);
0
0
0
0.5
0.100000001490116
0
0.100000001490116
0.100000001490116
0.200000002980232
-1
0