xxxxxxxxxx
83
class dash{
constructor(dashY){
this.Y=dashY;
this.movementFB=0;
this.gearY=0;
}
showdash(){
push();
strokeWeight(5)
fill(193, 154, 107);
beginShape();
curveVertex(0,this.Y);
curveVertex(0,this.Y);
curveVertex(windowWidth/2,this.Y-50);
curveVertex(windowWidth,this.Y);
curveVertex(windowWidth,windowHeight);
curveVertex(0,windowHeight);
curveVertex(0,this.Y);
curveVertex(0,this.Y);
endShape();
pop();
}
showgear(){
this.gearY=gearY;
rectMode(CENTER);
textSize(50);
fill(0);
rect(windowWidth*0.5,this.Y+110,150,300,50);
if(mouseIsPressed){
if(this.gearY<windowHeight*0.35){
this.movementFB=1;
}
else if(this.gearY>windowHeight*0.6){
this.movementFB=2;
}
else{
this.movementFB=0;
}
}
textAlign(CENTER);
textSize(50);
fill(0,128,0);
switch(this.movementFB){
case 0:
text('P',windowWidth*0.5,this.Y+110);
break;
case 1:
text('D',windowWidth*0.5,this.Y+110);
break;
case 2:
text('R',windowWidth*0.5,this.Y+110);
break;
}
textAlign(LEFT);
textSize(12);
return this.movementFB;
}
showScreen(wallstop){
rectMode(CENTER);
textSize(50);
textAlign(CENTER);
fill(0);
rect(windowWidth*0.75,this.Y+110,500,300,50);
fill(128,0,0);
if(wallstop==1){
text('OBJECT',windowWidth*0.75,this.Y+110);
text('DETECTED',windowWidth*0.75,this.Y+160);
text('AHEAD',windowWidth*0.75,this.Y+210);
}
else if(wallstop==2){
text('OBJECT',windowWidth*0.75,this.Y+110);
text('DETECTED',windowWidth*0.75,this.Y+160);
text('BEHIND',windowWidth*0.75,this.Y+210);
}
else{
text('No',windowWidth*0.75,this.Y+50);
text('OBJECT',windowWidth*0.75,this.Y+130);
text('DETECTED',windowWidth*0.75,this.Y+210);
}
textAlign(LEFT);
textSize(12);
}
}