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

32 lines
644 B
Plaintext
Raw Permalink Normal View History

var a = CHUNK_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--) {
chunk[i][j][k] = BLOCKS_TEST;
}
}
}
//populate
for (var k = a; k >= 0; k--) {
for (var j = a; j >= 0; j--) {
for (var i = a; i >= 0; i--) {
switch ( chunk[i][j][k] ) {
case BLOCKS_TEST:
var block_id = obj_block;
break;
default:
break;
}
var block = instance_create_layer(x + BLOCK_SIZE * i, y + BLOCK_SIZE * j, "Terrain", block_id);
with (block) {
z = other.z + BLOCK_SIZE * k;
chunk_id = other.id;
}
}
}
}