Added sprites to the bricks and touch control
This commit is contained in:
@ -7,15 +7,16 @@ class Brick {
|
||||
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.w = (32) - this.hspace;
|
||||
this.h = (32) - this.vspace;
|
||||
this.x = 2 + (this.w + this.hspace) * column;
|
||||
this.y = 80 + (this.h + this.vspace) * row;
|
||||
|
||||
this.img = [];
|
||||
switch (type) {
|
||||
case 2: this.lives = 2; break;
|
||||
case 3: this.lives = 3; break;
|
||||
default: this.lives = 1; break;
|
||||
case 2: this.lives = 2; this.img = [ resources.get('b31'),resources.get('b32') ]; break;
|
||||
case 3: this.lives = 3; this.img = [ resources.get('b31'),resources.get('b32'), resources.get('b33') ]; break;
|
||||
default: this.lives = 1; this.img = [ resources.get('b31') ]; break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,16 +29,13 @@ class Brick {
|
||||
|
||||
switch (this.lives) {
|
||||
case 1:
|
||||
ctx.fillStyle = 'blue';
|
||||
ctx.fillRect(this.x + 1, this.y, this.w, this.h);
|
||||
ctx.drawImage(this.img[0], this.x + 1, this.y);
|
||||
break;
|
||||
case 2:
|
||||
ctx.fillStyle = 'orange';
|
||||
ctx.fillRect(this.x + 1, this.y, this.w, this.h);
|
||||
ctx.drawImage(this.img[1], this.x + 1, this.y);
|
||||
break;
|
||||
case 3:
|
||||
ctx.fillStyle = 'red';
|
||||
ctx.fillRect(this.x + 1, this.y, this.w, this.h);
|
||||
ctx.drawImage(this.img[2], this.x + 1, this.y);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user