25 lines
648 B
JavaScript
25 lines
648 B
JavaScript
class PowerUpCoin {
|
|
constructor(game, cx, cy) {
|
|
this.game = game;
|
|
this.cx = cx;
|
|
this.cy = cy;
|
|
}
|
|
|
|
draw() {
|
|
this.game.ctx.fillStyle = '#fa0';
|
|
this.game.ctx.beginPath();
|
|
this.game.ctx.ellipse(this.cx, this.cy, Math.abs(this.game.powerUpRadius * Math.cos(this.game.coinAngle)), this.game.powerUpRadius, 0, 0, 2 * Math.PI);
|
|
this.game.ctx.fill();
|
|
}
|
|
|
|
hit() {
|
|
sounds.hitCoin.play();
|
|
this.game.increaseCoinCount();
|
|
this.remove();
|
|
}
|
|
|
|
remove() {
|
|
this.game.powerUps.splice(this.game.powerUps.findIndex(powerUp => powerUp === this), 1);
|
|
}
|
|
}
|