var coin1; function setup() { createCanvas(500, 500); coin1 = new Coin(250, 250); } function draw() { background(255); coin1.display(); coin1.setSize(coin1.getSize()+3); coin1.setOpacity(coin1.getOpacity()-3); } class Coin { constructor(x, y) { this.x = x; this.y = y; this.size = 20; this.opacity= 255; } getX() { return this.x; } getY() { return this.y; } getSize() { return this.size; } getOpacity() { return this.opacity; } setX(x) { this.x=x; } setY(y) { this.y=y; } setSize(size) { this.size=size; } setOpacity(opacity) { this.opacity=opacity; } moveUp() { this.y = this.y-1; } moveDown() { this.y = this.y+1; } moveRight() { this.x = this.x+1; } moveLeft() { this.x = this.x-1; } display() { fill(250, 218, 115, this.opacity); ellipse(this.x, this.y, this.size, this.size); } }