diff --git a/src/app/game-constants.ts b/src/app/game-constants.ts index 25f4fde..6205840 100644 --- a/src/app/game-constants.ts +++ b/src/app/game-constants.ts @@ -15,6 +15,7 @@ interface GameConfig extends Config { }, ships: Record, } @@ -27,10 +28,12 @@ export const GAME_CONFIG: GameConfig = { }, ships: { [ShipType.ship]: { - shotSpeed: 6, // speed in pixel + rocketSpeed: 6, + shotSpeed: 1, }, [ShipType.enemy]: { - shotSpeed: 4, // speed in pixel + rocketSpeed: 4, + shotSpeed: 0.1, }, }, powerUpConfig: [ diff --git a/src/app/models/pixijs/ship.ts b/src/app/models/pixijs/ship.ts index fe6b396..9097b5b 100644 --- a/src/app/models/pixijs/ship.ts +++ b/src/app/models/pixijs/ship.ts @@ -1,4 +1,5 @@ import { FrameObject, Texture } from 'pixi.js'; +import { GAME_CONFIG } from '../../game-constants'; import { GameShotService } from '../../services/game-shot.service'; import { AnimatedGameSprite } from './animated-game-sprite'; import { ShipType } from './ship-type.enum'; @@ -21,6 +22,8 @@ export class Ship extends AnimatedGameSprite { textures: Texture[] | FrameObject[], autoUpdate?: boolean) { super(speed, textures, autoUpdate); + + this.shotSpeed = GAME_CONFIG.ships[this.type].shotSpeed; } set energy(value: number) { diff --git a/src/app/services/game-shot.service.ts b/src/app/services/game-shot.service.ts index 6ec353b..30ea69d 100644 --- a/src/app/services/game-shot.service.ts +++ b/src/app/services/game-shot.service.ts @@ -29,7 +29,7 @@ export class GameShotService { shot(power: number, ship: Ship, up: boolean): void { const { x, y } = ship; for (let i = 1; i <= power; i++) { - const shot = new Rocket(up ? -GAME_CONFIG.ships[ship.type].shotSpeed : GAME_CONFIG.ships[ship.type].shotSpeed, this.laserAnimation !); + const shot = new Rocket(up ? -GAME_CONFIG.ships[ship.type].rocketSpeed : GAME_CONFIG.ships[ship.type].rocketSpeed, this.laserAnimation !); shot.reference = ship; shot.animationSpeed = 0.167; shot.play();