xxxxxxxxxx
30
class Car{
constructor(){
this.position = createVector(10,height/2);
// this.velocity = createVector(2,2);
// this.acceleration = createVector(0.01,0.01);
this.velocity = 2;
this.acceleration = 1;
}
display(){
ellipse(this.position.x,this.position.y,20,20);
}
update(){
this.position.x = this.position.x+this.velocity;
function keyPressed(){
if (keyCode == LEFT_ARROW){
this.velocity = this.velocity-this.acceleration;
print(1);
}
}
}}