import RoomSprite from './RoomSprite';

class Room extends Phaser.Group {

  constructor(game, parent, x,y, width, height) {
    super(game, parent, "room", true, true, Phaser.Physics.ARCADE);
    this.createRoom(game, x, y, width, height);
  }

  createRoom(game, x, y, width, height) {
    const room = new RoomSprite(game, x, y, width, height);
    this.add(room);
  }

  borders() {
    return this.roomSprite();
  }

  walls() {
    return this.children.filter(child => child.name === "RoomWall");
  }

  roomSprite() {
    return this.children.find(child => child.name === "RoomSprite");
  }

  overlapRoom(room) {
    console.log(this.roomSprite())
    this.roomSprite().overlapRoom(room);
  }

}

export default Room;
@@ -1,8 +1,29 @@
+const WallSize = 16;%0A
 import R
@@ -40,17 +40,17 @@
 from './
-R
+r
 oomSprit
@@ -119,16 +119,17 @@
 rent, x,
+ 
 y, width
@@ -311,82 +311,762 @@
     
-const room = new RoomSprite(game, x, y, width, height);%0A    this.add(room)
+for(let i = x - WallSize; i %3C x + width + WallSize; i += WallSize) %7B%0A      const upWall = this.addWall(game, i, y - WallSize);%0A      const downWall = this.addWall(game, i, y + height);%0A      this.add(upWall);%0A      this.add(downWall);%0A    %7D%0A    for(let j = y; j %3C y + height; j += WallSize) %7B%0A      const leftWall = this.addWall(game, x - WallSize, j);%0A      const rightWall = this.addWall(game, x + width, j);%0A      this.add(leftWall);%0A      this.add(rightWall);%0A    %7D%0A    const room = new RoomSprite(game, x, y, width, height);%0A    this.add(room);%0A  %7D%0A%0A  addWall(game, x, y) %7B%0A    let wall = game.add.sprite(x, y, 'Wall');%0A    wall.name = %22RoomWall%22;%0A    game.physics.enable(wall, Phaser.Physics.ARCADE);%0A    wall.body.immovable = true;%0A    return wall
 ;%0A  
@@ -1320,43 +1320,8 @@
 ) %7B%0A
-    console.log(this.roomSprite())%0A
     

add borders