# Collision without physics

**URL:** <https://phaser.discourse.group/t/collision-without-physics/6779>\
**Category:** Phaser 3\
**Created:** [June 25, 2020, 2:28pm UTC](https://phaser.discourse.group/t/collision-without-physics/6779 "2020-06-25T14:28:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vfb](https://avatars.discourse-cdn.com/v4/letter/v/58956e/32.png) [@vfb](https://phaser.discourse.group/u/vfb)\
**Post date:** [June 25, 2020, 2:28pm UTC](https://phaser.discourse.group/t/collision-without-physics/6779/1 "2020-06-25T14:28:27Z")

</div>

I have a sprite controlled by the player with CursorKeys (top, bottom, left, right)

I integrated a collision without physics between my sprite and a zone with _Phaser.Geom.Intersects.LineToRectangle()_ because I am testing each side of my sprite for collision.

It works fine, but if the right bound of my sprite collides with the zone, I can’t move my sprite up and down because the last point of the bound up and bound down also collides with the zone…

How can I do ?

sample here :

```
function() update {

[...]

 let leftBound = sprite.getBounds().getLineD();
 let rightBound = sprite.getBounds().getLineB();
 let upBound = sprite.getBounds().getLineA();
 let downBound = sprite.getBounds().getLineC();

 let leftIntersect = Phaser.Geom.Intersects.LineToRectangle(leftBound,this.zone.getBounds());
 let rightIntersect = Phaser.Geom.Intersects.LineToRectangle(rightBound,this.zone.getBounds());
 let upIntersect = Phaser.Geom.Intersects.LineToRectangle(upBound,this.zone.getBounds());
 let downIntersect = Phaser.Geom.Intersects.LineToRectangle(downBound,this.zone.getBounds());

 if (cursors.left.isDown && leftIntersect == false) {
        sprite.x -= SPEED;
        sprite.anims.play('walk',true);
 } else if (cursors.right.isDown && rightIntersect == false) {
        sprite.x += SPEED;
        sprite.anims.play('walk',true);
 } else if (cursors.up.isDown && upIntersect == false) {
        sprite.y += -SPEED;
        sprite.anims.play('walk',true);
 } else if(cursors.down.isDown && downIntersect == false) {
        sprite.y += SPEED;
        sprite.anims.play('walk',true);
 } else {
        sprite.anims.play('idle');
 }

}
```

---

<div class="post-metadata">

**Author:** ![Darko](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/darko/32/3335_2.png) [@Darko](https://phaser.discourse.group/u/Darko)\
**Post date:** [June 26, 2020, 5:50am UTC](https://phaser.discourse.group/t/collision-without-physics/6779/2 "2020-06-26T05:50:58Z")

</div>

Hello, I don’t know but just a random idea here ttrying to help…  
What about using rectangles wrapping the sprite where the size should be the SPEED I guess?  
e.g.

```javascript
let leftBound = new Phaser.Geom.Rectangle(sprite.x - SPEED, sprite.y, SPEED, sprite.height);

```

then check RectangleToRectangle instead…

```javascript
let leftIntersect = Phaser.Geom.Intersects.RectangleToRectangle(leftBound, zone.getBounds());

```

Adjusting something similar to:  
 ![imagen](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/c/c5c92086616506ff71c53c5d6bc3ed887eab7689.png)
