mirror of
https://github.com/owenlejeune/AirHockey.git
synced 2025-11-12 02:22:45 -05:00
changed how canvas width/height variables handled on server
This commit is contained in:
7
app.js
7
app.js
@@ -45,8 +45,8 @@ const DIR_RIGHT = 1;
|
||||
const DIR_NONE = 0;
|
||||
const dXY = 5;
|
||||
|
||||
var canvasWidth = 0;
|
||||
var canvasHeight = 0;
|
||||
var canvasWidth = 1000;
|
||||
var canvasHeight = 500;
|
||||
var windowsID = 0;
|
||||
var spectators = [];
|
||||
var player1 = {
|
||||
@@ -91,9 +91,6 @@ app.listen(PORT);
|
||||
|
||||
io.on("connection", (socket) => {
|
||||
socket.on("newWindowLoad", (data) => {
|
||||
var receivedData = JSON.parse(data);
|
||||
canvasWidth = (receivedData.width > canvasWidth) ? receivedData.width : canvasWidth;
|
||||
canvasHeight = (receivedData.height > canvasHeight) ? receivedData.height : canvasHeight;
|
||||
var responseObj = {player1: player1, player2: player2, puck: puck, id: windowsID};
|
||||
windowsID++;
|
||||
io.emit("newWindowLoadResponse", JSON.stringify(responseObj));
|
||||
|
||||
@@ -124,7 +124,7 @@ socket.on("collision", (data) => {
|
||||
})
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
socket.emit("newWindowLoad", JSON.stringify({width: canvas.width, height: canvas.height}));
|
||||
socket.emit("newWindowLoad", null);
|
||||
});
|
||||
|
||||
window.addEventListener("beforeunload", (e) => {
|
||||
|
||||
Reference in New Issue
Block a user