p5-breakout/tile.js

31 lines
624 B
JavaScript

//TILE CLASS. PUTS ALL THE BLOCKS IN A GRID AND GIVES THEM PROPERTIES.
class Tile {
constructor(i, j, colors) {
this.i = i;
this.j = j;
this.colors = colors
this.x = i * width / 13;
this.y = j * width / 64;
this.hit = false;
this.score = score
}
show() {
stroke(0);
fill(this.colors);
rect(this.x, this.y, width / 13, width / 64, 10);
}
colorRows(colors) {
this.colors = colors
return colors;
}
deleteOnHit() {
if (this.hit) {
grid[this.i].splice(this.j, 1)
}
}
}