Example room generation:
var cornerTile = "https://s3.amazonaws.com/files.d20.io/images/2766641/BQFOkdBneZUFnQUkFORrsA/thumb.jpg?1389918058";
var roomArrays = [
{roomType: "fourBYfour", srcImg: cornerTile, hFlip: true, vFlip: false, padLeft: 0, padTop: 0 },
{roomType: "fourBYfour", srcImg: cornerTile, hFlip: false, vFlip: false, padLeft: 140, padTop: 0 },
{roomType: "fourBYfour", srcImg: cornerTile, hFlip: true, vFlip: true, padLeft: 0, padTop: 140 },
{roomType: "fourBYfour", srcImg: cornerTile, hFlip: false, vFlip: true, padLeft: 140, padTop: 140 },
{roomType: "sixBYsix", srcImg: cornerTile, hFlip: true, vFlip: false, padLeft: 0, padTop: 0 },
{roomType: "sixBYsix", srcImg: cornerTile, hFlip: false, vFlip: false, padLeft: 280, padTop: 0 },
{roomType: "sixBYsix", srcImg: cornerTile, hFlip: true, vFlip: true, padLeft: 0, padTop: 280 },
{roomType: "sixBYsix", srcImg: cornerTile, hFlip: false, vFlip: true, padLeft: 280, padTop: 280 },
{roomType: "sixBYfour", srcImg: cornerTile, hFlip: true, vFlip: false, padLeft: 0, padTop: 0 },
{roomType: "sixBYfour", srcImg: cornerTile, hFlip: false, vFlip: false, padLeft: 280, padTop: 0 },
{roomType: "sixBYfour", srcImg: cornerTile, hFlip: true, vFlip: true, padLeft: 0, padTop: 140 },
{roomType: "sixBYfour", srcImg: cornerTile, hFlip: false, vFlip: true, padLeft: 280, padTop: 140 },
];
The units are 70x70 squares... so "fourBYfour" = four 70px squares by four 70px square.. you just define the library of rooms the generator can select from.
You call a room into existence with:
buildRoom(0,0,"fourBYfour");
Where the zeros are the x and y for the map in squares starting with 0,0 being the top left square.
The function is as follows.
buildRoom = function(leftValue, topValue, roomType) {
var lv = (leftValue * 70) + 140;
var tv = (topValue * 70) + 140;
_.each(roomArrays, function(indexRooms) {
if(indexRooms.roomType == roomType){
createObj("graphic", {_type: "graphic",_subtype: "token", _pageid: pageId, layer: "map", width: 280, height: 280,
left: lv + indexRooms.padLeft,
top: tv + indexRooms.padTop,
imgsrc: indexRooms.srcImg,
flipv: indexRooms.vFlip,
fliph: indexRooms.hFlip,
});
};
});
};