Skip to content

Commit 2ac0fff

Browse files
committed
move game/savedata to app/data
1 parent ed76c66 commit 2ac0fff

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
export const getData = <T>(key: string, def?: T): T | null => {
1+
// Related to load and save data
2+
3+
export function getData<T>(key: string, def?: T): T | null {
24
try {
35
return JSON.parse(window.localStorage[key]);
46
} catch {
@@ -10,8 +12,8 @@ export const getData = <T>(key: string, def?: T): T | null => {
1012
return null;
1113
}
1214
}
13-
};
15+
}
1416

15-
export const setData = (key: string, data: any) => {
17+
export function setData(key: string, data: any) {
1618
window.localStorage[key] = JSON.stringify(data);
17-
};
19+
}

src/core/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { App } from "../app/app";
2+
import { getData, setData } from "../app/data";
23
import { loadAseprite } from "../assets/aseprite";
34
import {
45
Asset,
@@ -134,7 +135,6 @@ import {
134135
setGravityDirection,
135136
} from "../game/gravity";
136137
import { getDefaultLayer, getLayers, layers, setLayers } from "../game/layers";
137-
import { getData, setData } from "../game/savedata";
138138
import { getSceneName, go, onSceneLeave, scene } from "../game/scenes";
139139
import { getBackground, setBackground } from "../gfx/bg";
140140
import { makeCanvas } from "../gfx/canvasBuffer";

src/game/gravity.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Gravity manipulation
2+
13
import { _k } from "../kaplay";
24
import { vec2 } from "../math/math";
35
import { type Vec2 } from "../math/Vec2";

src/game/layers.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { _k } from "../kaplay";
22
import { deprecateMsg } from "../utils/log";
33

4+
// Layering
5+
46
export function setLayers(layerNames: string[], defaultLayer: string) {
57
if (_k.game.layers) {
68
throw Error("Layers can only be assigned once.");

0 commit comments

Comments
 (0)