diff --git a/Box b/Box index 2da73a9..1abdcad 160000 --- a/Box +++ b/Box @@ -1 +1 @@ -Subproject commit 2da73a99eb1d11f5eeeb0cced4a583c6bfd8c211 +Subproject commit 1abdcad11297e329dda3eb908f6c4b82b8c28b3e diff --git a/assets/scripts/tilemap/generator.toy b/assets/scripts/tilemap/generator.toy index a4e31ae..19ab6a3 100644 --- a/assets/scripts/tilemap/generator.toy +++ b/assets/scripts/tilemap/generator.toy @@ -37,7 +37,7 @@ var themes: [string] const = [ var ROOM_MIN_WIDTH: int const = 4; //minimum safe value 4 var ROOM_MIN_HEIGHT: int const = 4; -var ROOM_MAX_WIDTH: int const = 12; +var ROOM_MAX_WIDTH: int const = 12; //minimum safe value ROOM_MIN_* + 1 var ROOM_MAX_HEIGHT: int const = 12; var CELL_WIDTH: int const = 16; //minimum safe value ROOM_MAX_* + 4 @@ -47,7 +47,7 @@ var CELL_COUNT_X: int const = 3; var CELL_COUNT_Y: int const = 3; -//raw string data +//raw interleaved tile data var tilemap: [int] = null; @@ -60,7 +60,7 @@ fn generateTilemapData(rng: opaque) { for (var i: int = 0; i < CELL_COUNT_X * CELL_WIDTH; i++) { tilemap.push(-1); //x tilemap.push(-1); //y - tilemap.push(-1); //collision + tilemap.push(0); //collision } } @@ -73,6 +73,7 @@ fn generateTilemapData(rng: opaque) { for (var j: int = 0; j < CELL_COUNT_Y; j++) { var metadata = generateRoomMetadata(rng, + //add a border within the cell that the doors can't touch i * CELL_WIDTH + 1, j * CELL_HEIGHT + 1, CELL_WIDTH - 2, @@ -97,6 +98,8 @@ fn generateTilemapData(rng: opaque) { //etch the corridors etchCorridors(roomData, corridorData, rng); + + //TODO: etch the walls with a filter, based on the room's themes } fn generateRoomMetadata(rng: opaque, left: int, top: int, width: int, height: int) { @@ -133,9 +136,9 @@ fn etchRoom(rng: opaque, metadata: [string: any]) { var w: int = metadata["w"]; var h: int = metadata["h"]; - //etch the floor-space (1-tile margin) - for (var j: int = y + 1; j < y + h - 1; j++) { - for (var i: int = x + 1; i < x + w - 1; i++) { + //etch the floor-space + for (var j: int = y; j < y + h; j++) { + for (var i: int = x; i < x + w; i++) { var floorIndex = rng.generateRandomNumber() % 4; //NOTE: there might not always be only 4 floor sprites tilemap[j * CELL_WIDTH * CELL_COUNT_X * 3 + i * 3 + 0] = tileset[theme + "-floor-" + string floorIndex][0]; tilemap[j * CELL_WIDTH * CELL_COUNT_X * 3 + i * 3 + 1] = tileset[theme + "-floor-" + string floorIndex][1]; @@ -143,51 +146,51 @@ fn etchRoom(rng: opaque, metadata: [string: any]) { } } - //create the string constants here, so refstring can do it's job - var T_WALL: [int] const = tileset[ theme + "-wall-t" ]; - var B_WALL: [int] const = tileset[ theme + "-wall-b" ]; - var L_WALL: [int] const = tileset[ theme + "-wall-l" ]; - var R_WALL: [int] const = tileset[ theme + "-wall-r" ]; + // //create the string constants here, so refstring can do it's job + // var T_WALL: [int] const = tileset[ theme + "-wall-t" ]; + // var B_WALL: [int] const = tileset[ theme + "-wall-b" ]; + // var L_WALL: [int] const = tileset[ theme + "-wall-l" ]; + // var R_WALL: [int] const = tileset[ theme + "-wall-r" ]; - //etch the walls of each room - for (var i: int = x; i < x + w; i++) { - tilemap[y * CELL_WIDTH * CELL_COUNT_X * 3 + i * 3 + 0] = T_WALL[0]; - tilemap[y * CELL_WIDTH * CELL_COUNT_X * 3 + i * 3 + 1] = T_WALL[1]; - tilemap[y * CELL_WIDTH * CELL_COUNT_X * 3 + i * 3 + 2] = T_WALL[2]; + // //etch the walls of each room + // for (var i: int = x; i < x + w; i++) { + // tilemap[y * CELL_WIDTH * CELL_COUNT_X * 3 + i * 3 + 0] = T_WALL[0]; + // tilemap[y * CELL_WIDTH * CELL_COUNT_X * 3 + i * 3 + 1] = T_WALL[1]; + // tilemap[y * CELL_WIDTH * CELL_COUNT_X * 3 + i * 3 + 2] = T_WALL[2]; - tilemap[(h + y - 1) * CELL_WIDTH * CELL_COUNT_X * 3 + i * 3 + 0] = B_WALL[0]; - tilemap[(h + y - 1) * CELL_WIDTH * CELL_COUNT_X * 3 + i * 3 + 1] = B_WALL[1]; - tilemap[(h + y - 1) * CELL_WIDTH * CELL_COUNT_X * 3 + i * 3 + 2] = B_WALL[2]; - } + // tilemap[(h + y - 1) * CELL_WIDTH * CELL_COUNT_X * 3 + i * 3 + 0] = B_WALL[0]; + // tilemap[(h + y - 1) * CELL_WIDTH * CELL_COUNT_X * 3 + i * 3 + 1] = B_WALL[1]; + // tilemap[(h + y - 1) * CELL_WIDTH * CELL_COUNT_X * 3 + i * 3 + 2] = B_WALL[2]; + // } - for (var j: int = y; j < y + h; j++) { - tilemap[j * CELL_WIDTH * CELL_COUNT_X * 3 + x * 3 + 0] = L_WALL[0]; - tilemap[j * CELL_WIDTH * CELL_COUNT_X * 3 + x * 3 + 1] = L_WALL[1]; - tilemap[j * CELL_WIDTH * CELL_COUNT_X * 3 + x * 3 + 2] = L_WALL[2]; + // for (var j: int = y; j < y + h; j++) { + // tilemap[j * CELL_WIDTH * CELL_COUNT_X * 3 + x * 3 + 0] = L_WALL[0]; + // tilemap[j * CELL_WIDTH * CELL_COUNT_X * 3 + x * 3 + 1] = L_WALL[1]; + // tilemap[j * CELL_WIDTH * CELL_COUNT_X * 3 + x * 3 + 2] = L_WALL[2]; - tilemap[j * CELL_WIDTH * CELL_COUNT_X * 3 + (x + w - 1) * 3 + 0] = R_WALL[0]; - tilemap[j * CELL_WIDTH * CELL_COUNT_X * 3 + (x + w - 1) * 3 + 1] = R_WALL[1]; - tilemap[j * CELL_WIDTH * CELL_COUNT_X * 3 + (x + w - 1) * 3 + 2] = R_WALL[2]; - } + // tilemap[j * CELL_WIDTH * CELL_COUNT_X * 3 + (x + w - 1) * 3 + 0] = R_WALL[0]; + // tilemap[j * CELL_WIDTH * CELL_COUNT_X * 3 + (x + w - 1) * 3 + 1] = R_WALL[1]; + // tilemap[j * CELL_WIDTH * CELL_COUNT_X * 3 + (x + w - 1) * 3 + 2] = R_WALL[2]; + // } - //etch the corners - tilemap[y * CELL_WIDTH * CELL_COUNT_X * 3 + x * 3 + 0] = tileset[ theme + "-corner-tl" ][0]; - tilemap[y * CELL_WIDTH * CELL_COUNT_X * 3 + x * 3 + 1] = tileset[ theme + "-corner-tl" ][1]; - tilemap[y * CELL_WIDTH * CELL_COUNT_X * 3 + x * 3 + 2] = tileset[ theme + "-corner-tl" ][2]; + // //etch the corners + // tilemap[y * CELL_WIDTH * CELL_COUNT_X * 3 + x * 3 + 0] = tileset[ theme + "-corner-tl" ][0]; + // tilemap[y * CELL_WIDTH * CELL_COUNT_X * 3 + x * 3 + 1] = tileset[ theme + "-corner-tl" ][1]; + // tilemap[y * CELL_WIDTH * CELL_COUNT_X * 3 + x * 3 + 2] = tileset[ theme + "-corner-tl" ][2]; - tilemap[(h + y - 1) * CELL_WIDTH * CELL_COUNT_X * 3 + x * 3 + 0] = tileset[ theme + "-corner-bl" ][0]; - tilemap[(h + y - 1) * CELL_WIDTH * CELL_COUNT_X * 3 + x * 3 + 1] = tileset[ theme + "-corner-bl" ][1]; - tilemap[(h + y - 1) * CELL_WIDTH * CELL_COUNT_X * 3 + x * 3 + 2] = tileset[ theme + "-corner-bl" ][2]; + // tilemap[(h + y - 1) * CELL_WIDTH * CELL_COUNT_X * 3 + x * 3 + 0] = tileset[ theme + "-corner-bl" ][0]; + // tilemap[(h + y - 1) * CELL_WIDTH * CELL_COUNT_X * 3 + x * 3 + 1] = tileset[ theme + "-corner-bl" ][1]; + // tilemap[(h + y - 1) * CELL_WIDTH * CELL_COUNT_X * 3 + x * 3 + 2] = tileset[ theme + "-corner-bl" ][2]; - tilemap[y * CELL_WIDTH * CELL_COUNT_X * 3 + (x + w - 1) * 3 + 0] = tileset[ theme + "-corner-tr" ][0]; - tilemap[y * CELL_WIDTH * CELL_COUNT_X * 3 + (x + w - 1) * 3 + 1] = tileset[ theme + "-corner-tr" ][1]; - tilemap[y * CELL_WIDTH * CELL_COUNT_X * 3 + (x + w - 1) * 3 + 2] = tileset[ theme + "-corner-tr" ][2]; + // tilemap[y * CELL_WIDTH * CELL_COUNT_X * 3 + (x + w - 1) * 3 + 0] = tileset[ theme + "-corner-tr" ][0]; + // tilemap[y * CELL_WIDTH * CELL_COUNT_X * 3 + (x + w - 1) * 3 + 1] = tileset[ theme + "-corner-tr" ][1]; + // tilemap[y * CELL_WIDTH * CELL_COUNT_X * 3 + (x + w - 1) * 3 + 2] = tileset[ theme + "-corner-tr" ][2]; - tilemap[(h + y - 1) * CELL_WIDTH * CELL_COUNT_X * 3 + (x + w - 1) * 3 + 0] = tileset[ theme + "-corner-br" ][0]; - tilemap[(h + y - 1) * CELL_WIDTH * CELL_COUNT_X * 3 + (x + w - 1) * 3 + 1] = tileset[ theme + "-corner-br" ][1]; - tilemap[(h + y - 1) * CELL_WIDTH * CELL_COUNT_X * 3 + (x + w - 1) * 3 + 2] = tileset[ theme + "-corner-br" ][2]; + // tilemap[(h + y - 1) * CELL_WIDTH * CELL_COUNT_X * 3 + (x + w - 1) * 3 + 0] = tileset[ theme + "-corner-br" ][0]; + // tilemap[(h + y - 1) * CELL_WIDTH * CELL_COUNT_X * 3 + (x + w - 1) * 3 + 1] = tileset[ theme + "-corner-br" ][1]; + // tilemap[(h + y - 1) * CELL_WIDTH * CELL_COUNT_X * 3 + (x + w - 1) * 3 + 2] = tileset[ theme + "-corner-br" ][2]; } fn generateCorridorData(rng: opaque) {