Current File : /home/jeshor13/11bsouth.com/VehiclesNOC/SoulMate.js
var SouldMate = function(x, y, c, z) {
  Vehicle.call(this, x, y, c, z)

  this.boundaries = function(k) {
    var desired = null;
    if (v[this.distantMate] !== this.SouldMate) {
      if (this.position.dist(v[this.distantMate].position) < width / 20) {
        if (random(1) < 0.8) {
          desired = createVector((v[this.distantMate].position.x), (v[this.distantMate].position.y));
        }
      }
    }

    if (this.position.x < d) {
      desired = createVector(this.maxspeed, this.velocity.y);
    } else if (this.position.x > width - d) {
      desired = createVector(-this.maxspeed, this.velocity.y);
    }

    if (this.position.y < d) {
      desired = createVector(this.velocity.x, this.maxspeed);
    } else if (this.position.y > height - d) {
      desired = createVector(this.velocity.x, -this.maxspeed);
    }


    if (desired !== null) {
      desired.normalize();
      desired.mult(this.maxspeed);
      var steer = p5.Vector.sub(desired, this.velocity);
      steer.limit(this.maxforce);
      this.applyForce(steer);
    }
  }
}


SouldMate.prototype = Object.create(Vehicle.prototype);
SouldMate.constructor = SouldMate;