example/bundle.js
// returns null if door can't be placed
returns null if door can't be placed
returns null if door can ' t be placed
_getAdjacentRoomDoorPosition(room, next) {
    let intersection, length, x, y
    if (((room.x+room.width) === (next.x - 1))  ||  ((room.x) === (next.x + next.width + 1))) {
      intersection = intersect1D(room.y, room.y+room.height, next.y, next.y+next.height)
      if (!intersection) { return null }
      length = (intersection[1] - intersection[0])
      y = intersection[0] + Math.round(random.next() * length)
      if ((room.x+room.width) === (next.x - 1)) {
        x = room.x+room.width
      } else {
        x = next.x + next.width
      }
      return { x, y, direction: 'EAST' }
    }
    if (((room.y+room.height) === (next.y - 1))  ||  ((room.y) === (next.y + next.height + 1))) {
      intersection = intersect1D(room.x, room.x+room.width, next.x, next.x+next.width)
      if (!intersection) { return null }
      length = (intersection[1] - intersection[0])
      x = intersection[0] + Math.round(random.next() * length)
      if ((room.y+room.height) === (next.y - 1)) {
        y = room.y+room.height
      } else {
        y = next.y + next.height
      }
      return { x, y, direction: 'NORTH' }
    }
    return null
  }
_getAdjacentRoomDoorPosition ( room , next ) { let intersection , length , x , y if ( ( ( room . x + room . width ) === ( next . x - 1 ) ) || ( ( room . x ) === ( next . x + next . width + 1 ) ) ) { intersection = intersect1D ( room . y , room . y + room . height , next . y , next . y + next . height ) if ( ! intersection ) { return null } length = ( intersection [ 1 ] - intersection [ 0 ] ) y = intersection [ 0 ] + Math . round ( random . next ( ) * length ) if ( ( room . x + room . width ) === ( next . x - 1 ) ) { x = room . x + room . width } else { x = next . x + next . width } return { x , y , direction : 'EAST' } } if ( ( ( room . y + room . height ) === ( next . y - 1 ) ) || ( ( room . y ) === ( next . y + next . height + 1 ) ) ) { intersection = intersect1D ( room . x , room . x + room . width , next . x , next . x + next . width ) if ( ! intersection ) { return null } length = ( intersection [ 1 ] - intersection [ 0 ] ) x = intersection [ 0 ] + Math . round ( random . next ( ) * length ) if ( ( room . y + room . height ) === ( next . y - 1 ) ) { y = room . y + room . height } else { y = next . y + next . height } return { x , y , direction : 'NORTH' } } return null }
returns null if door can't be placed
returns null if door can ' t be placed
// check if rooms are lined up on x axis ( side by side with 1 space between) // TODO: ensure the space isnt occupied with anything // check if rooms are lined up on y axis ( on top of each other with 1 space between) // TODO: ensure the space isnt occupied with anything