showing results for - "how to make a collision function in p5 js"
Kelian
02 Nov 2017
1// Method
2collidesWith(x, y, w, h) {
3    return (
4      (this.x > x &&
5        this.x < x + w &&
6        this.y > y &&
7        this.y < y + h) ||
8      (this.x + this.width > x &&
9        this.x + this.width < x + w &&
10        this.y > y &&
11        this.y < y + h) ||
12      (this.x + this.width > x &&
13        this.x + this.width < x + w &&
14        this.y + this.height > y &&
15        this.y + this.height < y + h) ||
16      (this.x > x &&
17        this.x < x + w &&
18        this.y + this.height > y &&
19        this.y + this.height < y + h)
20    );
21  }