authoritative server OK
+ TODO actual matchmaking
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
|
||||
import {GameArea} from "./class/GameArea.js";
|
||||
import * as d from "./draw.js";
|
||||
import {gameLoop, newRound} from "./gameLoop.js"
|
||||
// import * as c from "./constants.js"
|
||||
import {gameLoop} from "./gameLoop.js"
|
||||
import * as c from "./constants.js"
|
||||
import { GameComponentsClient } from "./class/GameComponentsClient.js";
|
||||
import {countdown} from "./utils.js";
|
||||
|
||||
import {socket} from "./ws.js"; socket; // no-op
|
||||
|
||||
/* Keys
|
||||
Racket 1: W/S
|
||||
Racket 2: Up/Down
|
||||
@@ -23,24 +25,24 @@ function matchmaking()
|
||||
function matchmakingComplete()
|
||||
{
|
||||
console.log("Match Found !"); // PLACEHOLDER, TODO draw on canvas
|
||||
countdown(3, startGame);
|
||||
}
|
||||
|
||||
function startGame()
|
||||
function startGame() {
|
||||
countdown(c.matchStartDelay/1000, resumeGame);
|
||||
}
|
||||
|
||||
function resumeGame()
|
||||
{
|
||||
// Start
|
||||
d.drawInit();
|
||||
window.addEventListener('keydown', function (e) {
|
||||
pong.addKey(e.key);
|
||||
});
|
||||
window.addEventListener('keyup', function (e) {
|
||||
pong.deleteKey(e.key);
|
||||
});
|
||||
pong.interval = window.setInterval(gameLoop, 15); // min interval on Firefox seems to be 15. Chrome can go lower.
|
||||
setTimeout(newRound, 1000);
|
||||
pong.interval = window.setInterval(gameLoop, c.gameLoopIntervalMS);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
export {matchmaking, matchmakingComplete}
|
||||
export {matchmaking, matchmakingComplete, startGame}
|
||||
|
||||
Reference in New Issue
Block a user