You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

39 lines
749 B

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;
}
}
}