summaryrefslogtreecommitdiff
path: root/client/src/logic/logic.ts
diff options
context:
space:
mode:
authorTyler Murphy <tylerm@tylerm.dev>2023-06-17 22:48:56 -0400
committerTyler Murphy <tylerm@tylerm.dev>2023-06-17 22:48:56 -0400
commit97c78292fef34a39552a4d983413b01e185a49aa (patch)
tree615c48125fe9a5a62b2d0826362dcbccf5721696 /client/src/logic/logic.ts
parentlayout changed (diff)
downloadtuxman-97c78292fef34a39552a4d983413b01e185a49aa.tar.gz
tuxman-97c78292fef34a39552a4d983413b01e185a49aa.tar.bz2
tuxman-97c78292fef34a39552a4d983413b01e185a49aa.zip
export and load maps
Diffstat (limited to 'client/src/logic/logic.ts')
-rw-r--r--client/src/logic/logic.ts50
1 files changed, 14 insertions, 36 deletions
diff --git a/client/src/logic/logic.ts b/client/src/logic/logic.ts
index 1cca2b7..dd6e21d 100644
--- a/client/src/logic/logic.ts
+++ b/client/src/logic/logic.ts
@@ -1,10 +1,13 @@
-import { genItems, loadMap, getMap } from "../map.js";
+import { genItems, genMap, getMap, decompressMap } from "../map.js";
import { updatePlayers } from "./players.js"
import { updateUI } from "./ui.js"
import { updateMovement } from "./movement.js"
import { updateItems } from "./items.js"
import { GameState, Input } from "../types.js";
+const maps = {
+ [0]: 'EwRgPqYgNDew+TEuW6AGT2u59mPI/PeLZclSys1AhSgThJcJb2bdq7p5rupV2DYaVFCKI9HwFDiWACyxyK5WpCqArOPSCeuqfUnzDwaGbMyT3FAGZT0ABznD9ybWv0LLq61kz4S0M9WRMANnVVDUi1AHYdQxt+dyNEhJNiNk8A3npkiVSmcUEM6E5C/wL86rlivLqxaVymltggA='
+}
export const InitialState: GameState = {
started: false,
@@ -32,7 +35,7 @@ export const onLogic = (
}
if (startPressed && !data.started) {
- initMap(data)
+ initMap(data, 0)
data.started = true;
}
@@ -40,41 +43,16 @@ export const onLogic = (
}
-const initMap = (data: GameState) => {
-
- document.getElementById("lobby").style.display = "none"
-
- data.mapId = 0
+const initMap = (gameData: GameState, mapId: number)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- data.items = genItems(getMap(0))
+ let map = getMap(mapId)
+ if (!map) {
+ let {width, height, data} = decompressMap(maps[mapId])
+ map = genMap(width, height, data, mapId)
+ }
+
+ gameData.items = genItems(map)
}