47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
|
|
initSpectator();
|
|
function initSpectator() {
|
|
// Wip
|
|
init();
|
|
}
|
|
|
|
import * as c from "./constants.js"
|
|
import * as en from "../shared_js/enums.js"
|
|
import { GameArea } from "./class/GameArea.js";
|
|
import { GameComponentsClient } from "./class/GameComponentsClient.js";
|
|
import { gameLoopSpectator } from "./gameLoop.js"
|
|
import { drawLoop } from "./draw.js";
|
|
import { initWebSocketSpectator } from "./ws.js";
|
|
import { initAudio } from "./audio.js";
|
|
|
|
|
|
/* TODO: A way to delay the init of variables, but still use "const" not "let" ? */
|
|
import { pong, gc } from "./global.js"
|
|
import { initPong, initGc, initMatchOptions, initStartFunction } from "./global.js"
|
|
|
|
function init()
|
|
{
|
|
initAudio(false);
|
|
|
|
// WIP matchOptions
|
|
let matchOptions: en.MatchOptions = en.MatchOptions.noOption;
|
|
initMatchOptions(matchOptions);
|
|
|
|
|
|
initPong(new GameArea());
|
|
initGc(new GameComponentsClient(matchOptions, pong.ctx));
|
|
initStartFunction(start);
|
|
initWebSocketSpectator(c.gameSessionIdPLACEHOLDER);
|
|
}
|
|
|
|
function start()
|
|
{
|
|
resume();
|
|
}
|
|
|
|
function resume()
|
|
{
|
|
pong.gameLoopInterval = window.setInterval(gameLoopSpectator, c.gameLoopIntervalMS);
|
|
pong.drawLoopInterval = window.setInterval(drawLoop, c.drawLoopIntervalMS);
|
|
}
|