Added the bricks (and improve the bouncing)

This commit is contained in:
2021-11-14 23:49:49 +01:00
parent 0f4a403edb
commit 7493713529
12 changed files with 303 additions and 111 deletions

30
Bricks.js Normal file
View 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;
}
}