Skip to content

Commit 3d72258

Browse files
author
Kitanga Nday
committed
Got game working again
1 parent 5603a5d commit 3d72258

16 files changed

+5419
-5503
lines changed

Design.md

Lines changed: 217 additions & 196 deletions
Large diffs are not rendered by default.

assets/snd/player_shoot_left.mp3

6.94 KB
Binary file not shown.

assets/snd/player_shoot_right.mp3

6.94 KB
Binary file not shown.

package-lock.json

Lines changed: 4039 additions & 4249 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"@babel/preset-typescript": "^7.13.0",
5050
"@babel/runtime": "^7.14.0",
5151
"@types/copy-webpack-plugin": "^8.0.0",
52+
"@types/eventemitter3": "^2.0.2",
5253
"@types/html-webpack-plugin": "^3.2.5",
5354
"@types/intersects": "^2.5.0",
5455
"@types/jest": "^26.0.24",
@@ -106,4 +107,4 @@
106107
"jest-canvas-mock"
107108
]
108109
}
109-
}
110+
}

src/Controller/CameraController.ts

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,39 @@
1-
import { Camera, Shake } from 'pixi-game-camera';
2-
import { Application, Container } from 'pixi.js';
3-
import { getApp } from '../Utils';
1+
import { Camera, Shake } from "pixi-game-camera";
2+
import { Application, Container } from "pixi.js";
3+
import { getApp } from "../Utils";
44

5-
export const CAMERA_CONTAINER_NAME = 'camera-main';
5+
export const CAMERA_CONTAINER_NAME = "camera-main";
66

77
export class CameraController {
8-
public static instance: CameraController | undefined;
8+
public static instance: CameraController | undefined;
99

10-
public static getInstance(): CameraController {
11-
if (!CameraController.instance) {
12-
CameraController.instance = new CameraController();
13-
}
10+
public static getInstance(): CameraController {
11+
if (!CameraController.instance) {
12+
CameraController.instance = new CameraController();
13+
}
1414

15-
return CameraController.instance;
16-
}
15+
return CameraController.instance;
16+
}
1717

18-
protected camera: Camera;
19-
protected cameraContainer!: Container;
20-
protected app: Application;
18+
protected camera: Camera;
19+
protected cameraContainer!: Container;
20+
protected app: Application;
2121

22-
private constructor() {
23-
this.app = getApp() as Application;
22+
private constructor() {
23+
this.app = getApp() as Application;
2424

25-
const options = {
26-
ticker: this.app.ticker
27-
};
25+
const options = {
26+
ticker: this.app.ticker,
27+
};
2828

29-
this.camera = new Camera(options);
29+
this.camera = new Camera(options);
30+
}
3031

31-
const stage = this.app.stage;
32+
public screenShake(intensity: number, duration: number): void {
33+
this.camera.effect(new Shake(this.app.stage, intensity, duration));
34+
}
3235

33-
if (stage && stage.getChildByName) {
34-
this.cameraContainer = stage.getChildByName(CAMERA_CONTAINER_NAME) as Container
35-
}
36-
}
37-
38-
public screenShake(intensity: number, duration: number): void {
39-
this.camera.effect(new Shake(this.app.stage, intensity, duration));
40-
}
36+
public resetCamera(): void {
37+
this.app.stage.position.set(0, 0);
38+
}
4139
}

src/Controller/EventController.ts

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
import EventEmitter from 'eventemitter3';
2-
import { AnimationNames } from '../constants';
1+
import EventEmitter from "eventemitter3";
2+
import { AnimationNames } from "../constants";
33

44
export class EventController {
5-
public static instance: EventController | undefined;
5+
public static instance: EventController | undefined;
66

7-
public static getInstance(): EventController {
8-
if (!EventController.instance) {
9-
EventController.instance = new EventController();
10-
}
7+
public static getInstance(): EventController {
8+
if (!EventController.instance) {
9+
EventController.instance = new EventController();
10+
}
1111

12-
return EventController.instance;
13-
}
12+
return EventController.instance;
13+
}
1414

15-
protected eventEmitter: EventEmitter;
15+
protected eventEmitter: EventEmitter;
1616

17-
private constructor() {
18-
this.eventEmitter = new EventEmitter();
19-
}
17+
private constructor() {
18+
this.eventEmitter = new EventEmitter();
19+
}
2020

21-
public on<T extends unknown[]>(event: AnimationNames, callback: (...props: unknown[] | T) => void): void {
22-
this.eventEmitter.on(event, callback);
23-
}
21+
public on<T extends unknown[]>(event: AnimationNames, callback: (...props: unknown[] | T) => void): void {
22+
this.eventEmitter.on(event, callback);
23+
}
2424

25-
public emit<T extends unknown[]>(event: AnimationNames, ...props: unknown[] | T): void {
26-
this.eventEmitter.emit(event, ...props);
27-
}
28-
}
25+
public emit<T extends unknown[]>(event: AnimationNames, ...props: unknown[] | T): void {
26+
this.eventEmitter.emit(event, ...props);
27+
}
28+
}

0 commit comments

Comments
 (0)