xxxxxxxxxx
53
// Emoji.js
class Emoji {
constructor(x, y) {
this.x = x;
this.y = y;
this.velocityX = random(-1, 1);
this.velocityY = random(-1, 1);
}
update() {
this.x += this.velocityX;
this.y += this.velocityY;
if (this.x > width || this.x < 0) this.velocityX *= -1;
if (this.y > height || this.y < 0) this.velocityY *= -1;
}
display() {
push();
translate(this.x, this.y);
this.drawHead();
this.drawEye(180, 180);
this.drawEye(220, 180);
this.drawMouth();
pop();
}
drawHead() {
fill(colours.light);
ellipse(200, 200, 200);
}
drawEye(x, y) {
fill(colours.dark);
ellipse(x, y, 20, 20);
}
drawMouth() {
fill(colours.dark);
rect(150, 200, 100, 15);
}
}