Commit 245a77fa authored by Yannick Armand's avatar Yannick Armand

Ajout du lance-flammes

parent 612cc3e5
......@@ -15,6 +15,7 @@ import RocketLauncher from './weapon/RocketLauncher'
import Shotgun from './weapon/Shotgun'
import SmokeGrenade from './weapon/SmokeGrenade'
import SubmachineGun from './weapon/SubmachineGun'
import Flamethrower from './weapon/Flamethrower';
type Direction = 'front' | 'back' | 'side-right' | 'side-left'
......@@ -89,6 +90,7 @@ export default class Player implements Entity {
new SmokeGrenade(game),
new SubmachineGun(game),
new Shotgun(game),
new Flamethrower(game),
]
this.currentWeaponIndex = 0
......
......@@ -38,3 +38,8 @@ export function clamp(num: number, min: number, max: number): number {
export function rand(min: number, max: number): number {
return Math.floor(Math.random() * (max - min + 1)) + min
}
// Converti des radians en degrés
export function radiansToDegrees(radians: number): number {
return radians * (180 / Math.PI)
}
import Game from '../Game'
import Particle from '../Particle'
import Point from '../Point'
import { radiansToDegrees } from '../Util'
import Weapon from './Weapon'
import Game from '../Game'
import WeaponName from './WeaponName'
export default class Flamethrower extends Weapon {
......@@ -14,10 +16,31 @@ export default class Flamethrower extends Weapon {
// Tir du joueur
public fire(position: Point, angle: number): boolean {
return false
angle = -radiansToDegrees(angle)
for (let i = 0 ; i < 3 ; i++) {
const particle = new Particle(this.getGame())
.setPosition(position.clone())
.setSpeed(180, 220)
.setLifetime(0.3, 0.7)
.setRadius(3, 6)
.setAngle(angle - 30, angle + 30)
.setColor([
'rgb(255, 0, 0)',
'rgb(255, 140, 0)',
'rgb(255, 215, 0)',
])
this.getGame().addParticle(particle)
}
return true
}
// Affichage de la miniature
public renderMiniature(ctx: CanvasRenderingContext2D): void {
const img = this.getGame().getImageManager().getImage('weapons-miniatures')
ctx.drawImage(img, 7 * 16, 0, 16, 16, 0, 0, 16, 16)
}
}
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