Added the bricks (and improve the bouncing)
This commit is contained in:
30
Bricks.js
Normal file
30
Bricks.js
Normal file
@ -0,0 +1,30 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user