audio
+ client prediction
This commit is contained in:
@@ -5,6 +5,8 @@ import {matchmaking, matchmakingComplete, startGame} from "./pong.js";
|
||||
import * as en from "../shared_js/enums.js"
|
||||
import { Racket } from "../shared_js/class/Rectangle.js";
|
||||
import { sleep } from "./utils.js";
|
||||
import * as c from "./constants.js"
|
||||
import {soundRoblox} from "./audio.js"
|
||||
|
||||
const wsPort = 8042;
|
||||
const wsUrl = "ws://" + document.location.hostname + ":" + wsPort + "/pong";
|
||||
@@ -88,6 +90,12 @@ async function gameUpdate(data: ev.EventGameUpdate)
|
||||
|
||||
function scoreUpdate(data: ev.EventScoreUpdate)
|
||||
{
|
||||
if (clientInfo.side === en.PlayerSide.left && data.scoreRight > gc.scoreRight.value) {
|
||||
soundRoblox.play();
|
||||
}
|
||||
else if (clientInfo.side === en.PlayerSide.right && data.scoreLeft > gc.scoreLeft.value) {
|
||||
soundRoblox.play();
|
||||
}
|
||||
gc.scoreLeft.value = data.scoreLeft;
|
||||
gc.scoreRight.value = data.scoreRight;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user