summaryrefslogtreecommitdiff
path: root/client/src/main.ts
diff options
context:
space:
mode:
authorTyler Murphy <tylerm@tylerm.dev>2023-06-25 18:19:26 -0400
committerTyler Murphy <tylerm@tylerm.dev>2023-06-25 18:19:26 -0400
commit0281233cbdc76e065a812780de0325fcfbd4e660 (patch)
tree51b8049b98de607fbb84ded183787a3958fc93f3 /client/src/main.ts
parentexport and load maps (diff)
downloadtuxman-0281233cbdc76e065a812780de0325fcfbd4e660.tar.gz
tuxman-0281233cbdc76e065a812780de0325fcfbd4e660.tar.bz2
tuxman-0281233cbdc76e065a812780de0325fcfbd4e660.zip
ghost
Diffstat (limited to 'client/src/main.ts')
-rw-r--r--client/src/main.ts24
1 files changed, 21 insertions, 3 deletions
diff --git a/client/src/main.ts b/client/src/main.ts
index b5ea424..9913d8b 100644
--- a/client/src/main.ts
+++ b/client/src/main.ts
@@ -1,12 +1,17 @@
import { Game } from "./net/game.js";
import { InitialState, onLogic } from "./logic/logic.js";
import { startGraphicsUpdater } from "./renderer.js";
-import { GameKeyMap, Frame, Key, Player } from "./types.js";
+import { GameKeyMap, Frame, Key, Player, GAME_MAP_COUNT, Vec2 } from "./types.js";
+import { checkMap, decompressMap, genMap } from "./map.js";
const join = document.getElementById("join")
const lobby = document.getElementById("lobby")
const mapeditor = document.getElementById("mapeditor")
+const maps = {
+ [0]: 'EwRgPqYgNDew+TEuW6AGT2u59mPI/PeLZclSys1AhSgThJcJb2bdq7p5rupV2DYaVFCKI9HwFDiWACyxyK5WpCqArOPSCeuqfUnzDwaGbMyT3FAGZT0ABznD9ybWv0LLq61kz4S0M9WRMANnVVDUi1AHYdQxt+dyNEhJNiNk8A3npkiVSmcUEM6E5C/wL86rlivLqxaVymltggA='
+}
+
join.onsubmit = async function(event) {
event.preventDefault()
@@ -23,8 +28,19 @@ join.onsubmit = async function(event) {
return
}
- join.style.display = "none"
- mapeditor.style.display = "none"
+ for (let mapId = 0; mapId < GAME_MAP_COUNT; mapId++) {
+ let {width, height, data} = decompressMap(maps[0]) // for now
+ let map = genMap(width, height, data, mapId)
+ let [success, result] = checkMap(map)
+
+ if (!success) {
+ alert(result)
+ return
+ }
+
+ map.spawns = result as Vec2[]
+
+ }
startGame(room_code, player_name)
}
@@ -48,6 +64,8 @@ const onLoad = (startData: Frame) => {
return false
}
+ join.style.display = "none"
+ mapeditor.style.display = "none"
lobby.style.display = ""
return true