example/bundle.js
// convert AABBs to grid, setting id of each item in cell.
convert AABBs to grid, setting id of each item in cell.
convert AABBs to grid setting id of each item in cell .
_buildGrid() {
    const grid = []
    for (let i = 0, end = (this.design.dimensions.width*this.design.dimensions.height)-1, asc = 0 <= end; asc ? i <= end : i >= end; asc ? i++ : i--) {
      grid.push(1)
    }
    for (let obj of Array.from(this.objects)) {
      for (let row = obj.y, end1 = (obj.y+obj.height)-1, asc1 = obj.y <= end1; asc1 ? row <= end1 : row >= end1; asc1 ? row++ : row--) {
        for (let col = obj.x, end2 = (obj.x+obj.width)-1, asc2 = obj.x <= end2; asc2 ? col <= end2 : col >= end2; asc2 ? col++ : col--) {
          const idx = (row * this.design.dimensions.width) + col
          grid[idx] = 0
        }
      }
    }
    return grid
  }
_buildGrid ( ) { const grid = [ ] for ( let i = 0 , end = ( this . design . dimensions . width * this . design . dimensions . height ) - 1 , asc = 0 <= end ; asc ? i <= end : i >= end ; asc ? i ++ : i -- ) { grid . push ( 1 ) } for ( let obj of Array . from ( this . objects ) ) { for ( let row = obj . y , end1 = ( obj . y + obj . height ) - 1 , asc1 = obj . y <= end1 ; asc1 ? row <= end1 : row >= end1 ; asc1 ? row ++ : row -- ) { for ( let col = obj . x , end2 = ( obj . x + obj . width ) - 1 , asc2 = obj . x <= end2 ; asc2 ? col <= end2 : col >= end2 ; asc2 ? col ++ : col -- ) { const idx = ( row * this . design . dimensions . width ) + col grid [ idx ] = 0 } } } return grid }
convert AABBs to grid, setting id of each item in cell.
convert AABBs to grid setting id of each item in cell .
//grid = zeros [ @design.dimensions.width, @design.dimensions.height ] // start with assuming all spaces are filled // hollow out all entities (rooms, anteroom, tunnels, etc.) //if obj.type isnt 'door' //grid.set row, col, 0