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

  this.boundaries = function(k) {
    var desired = null;
    var shake = noise(millis());
    for (var i = 0; i < v.length; i++) {
      if (k != i) {
        if (this.position.dist(v[i].position) < width / 20) {
          if (random(1) < 0.8) {
            desired = createVector(v[i].velocity.x, v[i].velocity.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);
    }
  }

};

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