Commit 612cc3e5 authored by Yannick Armand's avatar Yannick Armand

Ajout du fusil à pompe

parent 95e0263b
......@@ -12,8 +12,9 @@ import Grenade from './weapon/Grenade'
import Gun from './weapon/Gun'
import Mine from './weapon/Mine'
import RocketLauncher from './weapon/RocketLauncher'
import Shotgun from './weapon/Shotgun'
import SmokeGrenade from './weapon/SmokeGrenade'
import SubmachineGun from './weapon/SubmachineGun';
import SubmachineGun from './weapon/SubmachineGun'
type Direction = 'front' | 'back' | 'side-right' | 'side-left'
......@@ -87,6 +88,7 @@ export default class Player implements Entity {
new RocketLauncher(game),
new SmokeGrenade(game),
new SubmachineGun(game),
new Shotgun(game),
]
this.currentWeaponIndex = 0
......
import Game from '../Game'
import Point from '../Point'
import Bullet from './projectile/Bullet'
import Weapon from './Weapon'
import Game from '../Game'
import WeaponName from './WeaponName'
export default class Shotgun extends Weapon {
......@@ -14,12 +15,34 @@ export default class Shotgun extends Weapon {
return 'shotgun'
}
// Tir du joueur
public fire(position: Point, angle: number): boolean {
return false
if (!this.canFire())
return false
this.decreaseAmmo()
this.resetLatency()
const bullet1 = new Bullet(this.getGame())
bullet1.fire(position.clone(), angle - 0.2)
const bullet2 = new Bullet(this.getGame())
bullet2.fire(position.clone(), angle - 0.1)
const bullet3 = new Bullet(this.getGame())
bullet3.fire(position.clone(), angle)
const bullet4 = new Bullet(this.getGame())
bullet4.fire(position.clone(), angle + 0.1)
const bullet5 = new Bullet(this.getGame())
bullet5.fire(position.clone(), angle + 0.2)
return true
}
// Affichage de la miniature
public renderMiniature(ctx: CanvasRenderingContext2D): void {
const img = this.getGame().getImageManager().getImage('weapons-miniatures')
ctx.drawImage(img, 5 * 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