aboutsummaryrefslogtreecommitdiff
path: root/test-client
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-06-17 00:04:34 +0200
committermetamuffin <metamuffin@disroot.org>2024-06-17 00:04:34 +0200
commitdd4b88a86a99f028bdfe66fef3c66170629f3cdc (patch)
tree6e9acd5148b18220cfe7de83b80cf47b1aef3449 /test-client
parentc10d66de1bd2ef04e4010223dcd82443a5d558f0 (diff)
downloadhurrycurry-dd4b88a86a99f028bdfe66fef3c66170629f3cdc.tar
hurrycurry-dd4b88a86a99f028bdfe66fef3c66170629f3cdc.tar.bz2
hurrycurry-dd4b88a86a99f028bdfe66fef3c66170629f3cdc.tar.zst
establish ws
Diffstat (limited to 'test-client')
-rw-r--r--test-client/index.html22
-rw-r--r--test-client/main.ts34
-rw-r--r--test-client/protocol.ts4
3 files changed, 60 insertions, 0 deletions
diff --git a/test-client/index.html b/test-client/index.html
new file mode 100644
index 00000000..12079351
--- /dev/null
+++ b/test-client/index.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+ <title>Undercooked - Test Client</title>
+ <script src="./main.js" type="module"></script>
+ <style>
+ body {
+ margin: 0px;
+ overflow: hidden;
+ background-color: black;
+ }
+ noscript {
+ color: white;
+ }
+ </style>
+ </head>
+ <body>
+ <noscript>the game is written in javascript btw.</noscript>
+ </body>
+</html>
diff --git a/test-client/main.ts b/test-client/main.ts
new file mode 100644
index 00000000..bc0872a6
--- /dev/null
+++ b/test-client/main.ts
@@ -0,0 +1,34 @@
+/// <reference lib="dom" />
+
+let ctx: CanvasRenderingContext2D;
+let canvas: HTMLCanvasElement;
+let ws: WebSocket
+document.addEventListener("DOMContentLoaded", () => {
+ ws = new WebSocket(`${window.location.protocol.endsWith("s:") ? "wss" : "ws"}://${window.location.hostname}:27032/`)
+ ws.onerror = console.error
+ ws.onmessage = m => {
+ console.log(JSON.parse(m.data));
+ }
+ ws.onclose = () => console.warn("close")
+ ws.onopen = () => console.warn("open")
+
+ canvas = document.createElement("canvas");
+ document.body.append(canvas)
+ ctx = canvas.getContext("2d")!
+ resize()
+ globalThis.addEventListener("resize", resize)
+ draw()
+})
+
+function resize() {
+ canvas.width = globalThis.innerWidth
+ canvas.height = globalThis.innerHeight
+}
+
+function draw() {
+ ctx.fillStyle = "black"
+ ctx.fillRect(0, 0, canvas.width, canvas.height)
+
+ requestAnimationFrame(draw)
+}
+
diff --git a/test-client/protocol.ts b/test-client/protocol.ts
new file mode 100644
index 00000000..9761f152
--- /dev/null
+++ b/test-client/protocol.ts
@@ -0,0 +1,4 @@
+
+
+export type PacketS = {}
+export type PacketC = {}