class LevelText{ constructor(level){ this.text = "Level " + level; this.pos = createVector(width / 2, height - 50); this.vel = createVector(0, -0.1); this.acc = createVector(0, -5); this.dim = createVector(textWidth(this.text), 50); } isActive(){ return this.pos.y > -this.dim.y; } display(){ push(); textSize(this.dim.y); fill(255, 0, 0); stroke(0); strokeWeight(5); textAlign(CENTER); translate(this.pos.x, this.pos.y); scale(2, 2 - (this.vel.y / 50)); text(this.text, 0, 0); pop(); } update(){ this.vel.add(this.acc); this.pos.add(this.vel); if (this.pos.y < height / 2 && this.acc.y != 8 && this.acc.y != -0.25){ this.acc.y = 8; } if (this.vel.y > 0){ this.acc.y = -0.25; } } }