import { CellMap } from "classes/MapHandler" ; import CollisionDetector from "./CollisionDetector" ; import Wall from "../Wall" ; class LevelMap { private collisionDetector : CollisionDetector ; constructor ( map ) { this . collisionDetector = new CollisionDetector ( map ) ; this . attachMap ( ) ; } public handleCollision ( targetPosition , currentPosition ) { return this . collisionDetector . handleCollision ( targetPosition , currentPosition ) ; } public setCollision ( position ) { return this . collisionDetector . setCollision ( position ) ; } private attachMap ( ) { this . collisionDetector . forEach ( ( position , cellInfo ) => { if ( cellInfo . current === " " ) return ; const insideOtherWalls = ! [ cellInfo . front , cellInfo . back , cellInfo . left , cellInfo . right ] . includes ( " " ) ; if ( insideOtherWalls ) return ; new Wall ( position , cellInfo ) ; } ) ; } } export default LevelMap ;