30 lines
674 B
JavaScript
30 lines
674 B
JavaScript
class Brick {
|
|
constructor(type, column, row) {
|
|
this.type = type;
|
|
this.row = row;
|
|
this.column = column;
|
|
|
|
this.vspace = 2;
|
|
this.hspace = 2;
|
|
|
|
this.w = (360/8) -this.hspace;
|
|
this.h = (20) - this.vspace;
|
|
this.x = (this.w +this.hspace)*column;
|
|
this.y = 80 + (this.h +this.vspace)*row;
|
|
|
|
this.alive = true;
|
|
}
|
|
|
|
update(ctx) {
|
|
if (!this.alive) return false;
|
|
|
|
switch(this.type) {
|
|
case 1:
|
|
ctx.fillStyle = 'blue';
|
|
ctx.fillRect(this.x+1, this.y, this.w, this.h);
|
|
break;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
} |