xxxxxxxxxx
50
class Tile {
constructor(x_,y_,type_,borderT_,borderR_,borderB_,borderL_) {
this.x = x_;
this.y = y_;
this.size = tileSize;
this.type = type_; // start, goal, arenaA, arenaB
this.borderT = borderT_;
this.borderR = borderR_;
this.borderB = borderB_;
this.borderL = borderL_;
// make objects out of borders
if(this.borderT) {
rubicons.push(new LineSeg(createVector(this.x,this.y),createVector(this.x + this.size,this.y)));
}
if(this.borderR) {
rubicons.push(new LineSeg(createVector(this.x + this.size,this.y),createVector(this.x + this.size,this.y + this.size)));
}
if(this.borderB) {
rubicons.push(new LineSeg(createVector(this.x,this.y + this.size),createVector(this.x + this.size,this.y + this.size)));
}
if(this.borderL) {
rubicons.push(new LineSeg(createVector(this.x,this.y),createVector(this.x,this.y + this.size)));
}
} // constructor
show() {
fill(0,0,255,50);
noStroke();
rect(this.x,this.y,this.size,this.size);
stroke(0);
strokeCap(SQUARE);
strokeWeight(4);
if(this.borderT) {
line(this.x,this.y,this.x + this.size,this.y);
}
if(this.borderR) {
line(this.x + this.size,this.y,this.x + this.size,this.y + this.size);
}
if(this.borderB) {
line(this.x,this.y + this.size,this.x + this.size,this.y + this.size);
}
if(this.borderL) {
line(this.x,this.y,this.x,this.y + this.size);
}
}
} // Tile