Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

p5js class

class Diamond {
  //The constructor, uses to arguments that you inputted
  constructor diamond(x, y) {
    this.x = x;
    this.y = y;
  }
  
  //A function of diamond
  update() {
    print("I'm a diamond!");
  }
}

//Create an instance
var d = new Diamond(50, 100);
//call d fucntion
d.update();
 
PREVIOUS NEXT
Tagged: #class
ADD COMMENT
Topic
Name
2+4 =