var h1;
var h2;
function HLine(y, s) {
this.ypos = y;
this.speed = s;
}
HLine.prototype.update = function() {
this.ypos += this.speed;
if (this.ypos > height) {
this.ypos = 0;
}
line(0, this.ypos, width, this.ypos);
}
function setup() {
createCanvas(100, 100);
h1 = new HLine(20, 2.0);
h2 = new HLine(50, 2.5);
}
function draw() {
background(204);
h1.update();
h2.update();
}
They are created like functions, and thus, there's no special Class syntax. You can read more about this on Mozilla MDN