Answers for "how to make a collision function in p5.js"

1

how to make a collision function in p5.js

// Method
collidesWith(x, y, w, h) {
    return (
      (this.x > x &&
        this.x < x + w &&
        this.y > y &&
        this.y < y + h) ||
      (this.x + this.width > x &&
        this.x + this.width < x + w &&
        this.y > y &&
        this.y < y + h) ||
      (this.x + this.width > x &&
        this.x + this.width < x + w &&
        this.y + this.height > y &&
        this.y + this.height < y + h) ||
      (this.x > x &&
        this.x < x + w &&
        this.y + this.height > y &&
        this.y + this.height < y + h)
    );
  }
Posted by: Guest on July-20-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language