Skip to content

Commit ed76c66

Browse files
committed
refactor: move initEvents to appEvents in app/
1 parent e71149a commit ed76c66

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/events/initEvents.ts renamed to src/app/appEvents.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import { _k } from "../kaplay";
55
import { clamp } from "../math/clamp";
66
import { toFixed } from "../utils/numbers";
77

8-
export function initEvents() {
8+
// Events used at the start of a game
9+
10+
export function initAppEvents() {
911
_k.app.onHide(() => {
1012
if (!_k.globalOpt.backgroundAudio) {
1113
_k.audio.ctx.suspend();

src/game/scenes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { initAppEvents } from "../app/appEvents";
12
import type { KEventController } from "../events/events";
2-
import { initEvents } from "../events/initEvents";
33
import { _k } from "../kaplay";
44
import { Mat23, vec2 } from "../math/math";
55

@@ -36,7 +36,7 @@ export function go(name: SceneName, ...args: unknown[]) {
3636
});
3737

3838
_k.game.root.clearEvents();
39-
initEvents();
39+
initAppEvents();
4040

4141
// cam
4242
_k.game.cam = {

src/kaplay.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// The definitive version!
2+
import { initAppEvents } from "./app/appEvents";
23
import type { ButtonsDef } from "./app/inputBindings";
34
import { getFailedAssets, loadProgress } from "./assets/asset";
45
import { loadSprite } from "./assets/sprite";
@@ -10,7 +11,6 @@ import boomSpriteSrc from "./data/assets/boom.png";
1011
import kaSpriteSrc from "./data/assets/ka.png";
1112
import { createCollisionSystem } from "./ecs/systems/createCollisionSystem";
1213
import { LCEvents, system } from "./ecs/systems/systems";
13-
import { initEvents } from "./events/initEvents";
1414
import { drawDebug } from "./gfx/draw/drawDebug";
1515
import { drawFrame } from "./gfx/draw/drawFrame";
1616
import { drawLoadScreen } from "./gfx/draw/drawLoadingScreen";
@@ -213,7 +213,7 @@ export const kaplay = <
213213
});
214214

215215
updateViewport();
216-
initEvents();
216+
initAppEvents();
217217

218218
// the exported ctx handle
219219
const ctx: KAPLAYCtx = createContext(game, app, audio, debug);

0 commit comments

Comments
 (0)