summaryrefslogtreecommitdiffstats
path: root/src/renderer/index.ts
blob: 490dbef7d223f5ea50d85d2163fc1c743af22307 (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
26
27
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);
};

module.hot?.accept();