summaryrefslogtreecommitdiffstats
path: root/src/renderer/index.ts
blob: 16f18d14a88d0fd7d97489d5c41ce4c725b927fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import './runtime/index.css';

import { GameContext } from './runtime/controller/gamecontext';

import { Renderer } from './runtime/view/renderer/renderer';

window.onload = async (): Promise<void> => {
	const app = document.getElementById('app');
	if (!app) return;

	const canvas = document.createElement('canvas');
	const renderer = new Renderer(canvas);

	const resize = (): void => {
		canvas.width = window.innerWidth;
		canvas.height = window.innerHeight;
		renderer.resize();
	};
	window.addEventListener('resize', resize);
	resize();

	app.append(canvas);

	GameContext.load(renderer);
};