xxxxxxxxxx
120
class cmoGrid {
// Contructor
constructor( tempMyNumber, tempX, tempY) {
this.myNumber = tempMyNumber;
this.x = tempX;
this.y = tempY;
this.cmoCanvas=10;
this. fun = random(10);
this.closeby = false;
this.hideGrid=false;
print("YAY! I AM BORN");
}
keyReleased(){
if (key == 'h') {
hideGrid=!hideGrid;
}
}
cmoUpdate() {
if (dist(this.x, this.y, mouseX, mouseY) < cmoRolloverDistance) {
this.cmoCanvas = 30;
} else {
this.cmoCanvas = 10;
}
if (keyPressed) {
if (key == ' ') {
this.showGrid=!this.showGrid;
}
}
//hide grid & white background
if (!showGrid) {
background(255);
}
}
// Custom method for drawing the object
cmoDisplay() {
if (!this.hideGrid) {
if (this.closeby) {
fill(100,100);
strokeWeight(5);
} else {
fill(100,100);
strokeWeight(1);
}
} else {
stroke(0);
noFill();
strokeWeight(0);
}
ellipse(this.x, this.y, this.cmoCanvas, this.cmoCanvas);
}
cmoCheckCloseby() {
if (dist(this.x, this.y, mouseX, mouseY) < cmoRolloverDistance) {
this.cmoCanvas=30;
this.closeby = true;
} else {
this.cmoCanvas=10;
this.closeby = false;
}
}
//// return means the value of let [checkDistance] only exist when dist is < 20
checkDistance( xTemp, yTemp) {
if (dist(xTemp, yTemp, this.x, this.y) < 30) {
return true;
} else {
return false;
}
}
}