collision workey

This commit is contained in:
s-prechtl 2022-12-13 10:35:00 +01:00
parent a8681c0eb4
commit a464da424a
5 changed files with 33 additions and 10 deletions

View file

@ -31,9 +31,9 @@ class Pipe extends Entity implements Collidable {
}
collides(o: Entity): boolean {
return this.position.x < o.position.x + o.width && //inside left border
this.position.x + this.width > o.position.x && //but not outside right border
this.position.y < o.position.y + o.height && //inside top border
this.position.y + this.height > o.position.y; //but not outside bottom border
return this.position.x < (o.position.x + o.width) && //inside left border
(this.position.x + this.width) > o.position.x && //but not outside right border
this.position.y < (o.position.y + o.height) && //inside top border
(this.position.y + this.height) > o.position.y; //but not outside bottom border
}
}