{
class Brick {
constructor (x, y, width, height, type) {
this.x = x
this.y = y
this.width = width
this.height = height
this.type = type
this.graphic = 'default.png'
this.live = 10
}
print() {
return [this.x, this.y, this.width, this.height, this.type, this.graphic, this.live]
}
init () {
return "Dodano na plansze";
}
}
class BrickBlue extends Brick {
constructor(x, y, width, height, type) {
super(x, y, width, height, type);
this.live = 100;
this.graphic = 'blue.png'
}
}
class BrickRed extends Brick {
constructor(x, y, width, height, type) {
super(x, y, width, height, type);
this.live = 10;
this.graphic = 'red.png'
}
}
class BrickGreen extends Brick {
constructor(x, y, width, height, type) {
super(x, y, width, height, type);
this.live = 20;
this.graphic = 'green.png'
}
}
class BrickAnim extends Brick {
constructor(x, y, width, height, type, speed) {
super(x, y, width, height, type);
this.graphic = 'anim.png'
this.speed = speed
}
moveHorizontal() {
return `poruszam się poziomo z szybkością ${this.speed}`;
}
}
const green = new BrickGreen(1,1, 100, 100, 'brick')
const red = new BrickRed(2,2, 100, 100, 'brick')
const blue = new BrickBlue(3,3, 100, 100, 'brick')
const animBrick = new BrickAnim(100,100, 100, 100, 'anim', 300);
return [
[green.init(), red.init(), blue.init()],
[green.print(), red.print(), blue.print()],
animBrick, animBrick.moveHorizontal()
]
}