# Delete neighbour tiles too

**URL:** <https://phaser.discourse.group/t/delete-neighbour-tiles-too/5279>\
**Category:** Phaser 3\
**Created:** [February 21, 2020, 10:04am UTC](https://phaser.discourse.group/t/delete-neighbour-tiles-too/5279 "2020-02-21T10:04:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bartek477](https://avatars.discourse-cdn.com/v4/letter/b/f6c823/32.png) [@Bartek477](https://phaser.discourse.group/u/Bartek477)\
**Post date:** [February 21, 2020, 10:04am UTC](https://phaser.discourse.group/t/delete-neighbour-tiles-too/5279/1 "2020-02-21T10:04:26Z")

</div>

Hi!  
Im trying to write my own version of bomberman and I`ve got problem with explosion, which is deleting boxes correctly but unfortunatelly it kills its neighbours too (some of them, and not always…)

What I found is when overlap occurs it spot sometimes more boxes - why ?

Some of my code:  
this.boxesLayer = this.map.createDynamicLayer(“boxes”, this.tileset, 0, 0);  
this.physics.add.overlap(this.boxesLayer, this.explosions,  
this.destroyBoxes,null,this);

```
 destroyBoxes(explo,box)
{
    this.boxesLayer.removeTileAt(box.x,box.y);
    
}

    explode(){
    let range = this.player.range;
    let x = this.x;
    let y = this.y;
    let step = 32;
    let boxRight = false;
    let boxLeft = false;
    let boxUp = false;
    let boxDown = false;
    for(let i = 0; i < range; i++){
        if(!this.scene.blocksLayer.getTileAtWorldXY(x + i*step, y) && !boxRight) 
        new Explosion(this.scene,x + i*step, y);
        if(this.scene.boxesLayer.getTileAtWorldXY(x + i*step, y) || 
 this.scene.blocksLayer.getTileAtWorldXY(x + i*step, y))
            boxRight = true;

        if(!this.scene.blocksLayer.getTileAtWorldXY(x - i*step, y) && !boxLeft)
        new Explosion(this.scene,x - i*step, y);
        if(this.scene.boxesLayer.getTileAtWorldXY(x - i*step, y) || 
 this.scene.blocksLayer.getTileAtWorldXY(x - i*step, y))
            boxLeft = true;

        if(!this.scene.blocksLayer.getTileAtWorldXY(x, y+i*step) && !boxDown)
        new Explosion(this.scene,x, y+i*step);
        if(this.scene.boxesLayer.getTileAtWorldXY(x, y+i*step) || 
 this.scene.blocksLayer.getTileAtWorldXY(x, y+i*step))
            boxDown = true;

        if(!this.scene.blocksLayer.getTileAtWorldXY(x, y-i*step) && !boxUp)
        new Explosion(this.scene,x, y-i*step);
        if(this.scene.boxesLayer.getTileAtWorldXY(x, y-i*step) || 
this.scene.blocksLayer.getTileAtWorldXY(x, y-i*step))
            boxUp = true;
    }
}

```

![bomb1](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/a/ae904a7d492e891603078ed96b18ebf78a0ed7a3.png) ![bomb2](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/4/46cc5b455d77859e5a41355ecb502d814193e10d.png)

---

<div class="post-metadata">

**Author:** ![Bartek477](https://avatars.discourse-cdn.com/v4/letter/b/f6c823/32.png) [@Bartek477](https://phaser.discourse.group/u/Bartek477)\
**Post date:** [February 21, 2020, 12:35pm UTC](https://phaser.discourse.group/t/delete-neighbour-tiles-too/5279/2 "2020-02-21T12:35:50Z")

</div>

It even looks like my overlap function is used even if no overlapping is done :S

---

<div class="post-metadata">

**Author:** ![Bartek477](https://avatars.discourse-cdn.com/v4/letter/b/f6c823/32.png) [@Bartek477](https://phaser.discourse.group/u/Bartek477)\
**Post date:** [February 24, 2020, 12:30pm UTC](https://phaser.discourse.group/t/delete-neighbour-tiles-too/5279/3 "2020-02-24T12:30:29Z")

</div>

bump
