Commit b54c045d authored by Yannick Armand's avatar Yannick Armand

Seules les particules explosives font des dégâts

parent d2651853
......@@ -32,6 +32,7 @@ export default class Explosion {
.setLifetime(0.6, 2)
.setRadius(12, 24)
.setAngle(0, 360)
.setDamages(3)
particles.push(particle)
......
......@@ -16,8 +16,6 @@ const colors = [
*/
const PARTICLE_DAMAGES = 3
// Converti des degrés en radians
function degreesToRadians(degrees: number): number {
return degrees * (Math.PI / 180)
......@@ -48,6 +46,8 @@ export default class Particle implements Entity {
private color: string
private damages: number | null
// Créer une particule
public constructor(game: Game) {
this.game = game
......@@ -64,6 +64,8 @@ export default class Particle implements Entity {
this.speed = 0
this.color = 'rgb(255, 255, 255)'
this.damages = null
}
// Mise à jour d'une particule
......@@ -143,12 +145,21 @@ export default class Particle implements Entity {
return this
}
public setDamages(damages: number): this {
this.damages = damages
return this
}
public isAlive(): boolean {
return this.lifetime > 0
}
public onPlayerOverlaps(player: Player): void {
player.decreaseHealth(PARTICLE_DAMAGES)
if (!this.damages)
return
player.decreaseHealth(this.damages)
this.remove()
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment