minecraft-in-24h-jam/objects/obj_world/Create_0.gml

32 lines
709 B
Plaintext
Raw Permalink Normal View History

var a = WORLD_SIZE - 1;
z = 0;
//generate terrain
for (var k = a; k >= 0; k--) {
for (var j = a; j >= 0; j--) {
for (var i = a; i >= 0; i--) {
global.world_chunk[i][j][k] = CHUNKS_TEST;
}
}
}
//populate
for (var k = 1; k >= 0; k--) {
for (var j = a; j >= 0; j--) {
for (var i = a; i >= 0; i--) {
switch ( global.world_chunk[i][j][k] ) {
case CHUNKS_TEST:
var chunk_id = obj_chunk;
break;
default:
break;
}
var block = instance_create_layer(x + CHUNK_SIZE * BLOCK_SIZE * i, y + CHUNK_SIZE * BLOCK_SIZE * j, "Terrain", chunk_id);
with (block) {
z = other.z + CHUNK_SIZE * BLOCK_SIZE * k;
world_id = other.id;
}
}
}
}