xxxxxxxxxx
42
function Diggi(x,y,size){
this.pos = createVector(x,y);
this.vel = createVector();
this.acc = createVector();
this.color = color(random(255),random(255),random(255));
this.size = size;
this.life = true;
this.b = false;
this.maxSpeed = 10;
this.maxHeight = 100;
this.maxDepth = height;
this.speed = -0.5;
}
Diggi.prototype.behavoirs = function(){
var grav = this.gravity();
if(this.pos.y >= height) grav.mult(-1);
if(this.pos.y <= 0) grav.mult(1);
if(this.pos.x >= width) grav.mult(-1);
if(this.pos.x <= 0) grav.mult(1);
this.acc.add(grav);
}
Diggi.prototype.gravity = function(){
var gravC = 0.5;
var grav = createVector(0,gravC);
return grav;
}
Diggi.prototype.update = function(){
this.pos.add(this.vel);
this.vel.add(this.acc);
this.vel.limit(this.maxSpeed);
this.acc.mult(0);
}
Diggi.prototype.display = function(){
fill(this.color);
circle(this.pos.x,this.pos.y,this.size);
}