From 292257d627bd1dfeafd772ac6457e2f54c2b73ba Mon Sep 17 00:00:00 2001 From: Maks Jopek Date: Sun, 4 Apr 2021 01:53:24 +0200 Subject: One step closer to the end --- frontend/ts/startGame.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 frontend/ts/startGame.ts (limited to 'frontend/ts/startGame.ts') diff --git a/frontend/ts/startGame.ts b/frontend/ts/startGame.ts new file mode 100644 index 0000000..50ef068 --- /dev/null +++ b/frontend/ts/startGame.ts @@ -0,0 +1,27 @@ +function getCanvasAndCtx(): [HTMLCanvasElement, CanvasRenderingContext2D] { + let canvas = document.getElementsByTagName("canvas")[0], + ctx = canvas.getContext("2d"); + if (ctx === null) { + document.write("ur muther is fat, stop using IE"); + throw new Error("PLayer is using browser older that his mom"); + } else return [canvas, ctx]; +} +function setOpponents(data: object, body: string) { + let a = [ + { + id: 1, + color: "red", + } + ] + document.body.innerHTML = body; +} +export default async function startGame (data: object) { + let body = await (await fetch("/map.html")).text(); + setOpponents(data, body); + let [canvas, ctx] = getCanvasAndCtx(); + let img = new Image(600, 600); + img.width = 600; + img.height = 600; + img.src = "https://www.egierki.pl/app/uploads/2020/05/Ludo-Play.jpg"; + img.onload = () => ctx.drawImage(img, 0, 0); +} -- cgit v1.3.1