serveur de jeu - work in progress
This commit is contained in:
46
jeu/src/client/pongSpectator.ts
Normal file
46
jeu/src/client/pongSpectator.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user