diff options
Diffstat (limited to 'client/src/components')
-rw-r--r-- | client/src/components/GameCanvas.svelte | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/client/src/components/GameCanvas.svelte b/client/src/components/GameCanvas.svelte index ae8c1b0..ed16f33 100644 --- a/client/src/components/GameCanvas.svelte +++ b/client/src/components/GameCanvas.svelte @@ -1,6 +1,7 @@ <script lang="ts"> import { onMount } from "svelte"; import { loadAssets } from "@engine/config"; + import { Game } from "@engine/Game"; import { JumpStorm } from "../JumpStorm"; let canvas: HTMLCanvasElement; @@ -9,16 +10,18 @@ export let width: number; export let height: number; - let jumpStorm: JumpStorm; - - onMount(() => { + onMount(async () => { ctx = canvas.getContext("2d"); ctx.imageSmoothingEnabled = false; - loadAssets().then(() => { - jumpStorm = new JumpStorm(ctx); - jumpStorm.play(); - }); + await loadAssets(); + + const game = new Game(); + const jumpStorm = new JumpStorm(game); + + const url = new URL(document.location); + await jumpStorm.init(ctx, "http", "ws", url.host + "/api"); + jumpStorm.play(); }); </script> |