This commit is contained in:
Killian Marty 2023-11-19 18:23:15 +01:00
parent 63208cd293
commit 8d4b7a2376

View file

@ -14,13 +14,27 @@ app.get('/', (req, res) => {
res.send('Grand Tabernacle Auto VI'); res.send('Grand Tabernacle Auto VI');
}); });
players.push({
id: playerCount,
x: 0,
y: 0,
dir: 0,
visibleDir: 0,
name: playerCount.toString() + "joueur"
})
playerCount++;
function createNewPlayer(socket){ function createNewPlayer(socket){
var obj = { var obj = {
id: playerCount, id: playerCount,
x: 0, x: 0,
y: 0, y: 0,
dir: 0,
visibleDir: 0,
name: playerCount.toString() + "joueur" name: playerCount.toString() + "joueur"
} }
players.push(obj);
playerCount++;
socket.send(JSON.stringify({ socket.send(JSON.stringify({
type: "connect", type: "connect",
@ -37,8 +51,6 @@ function createNewPlayer(socket){
socket.id = obj.id; socket.id = obj.id;
connections.add(socket); connections.add(socket);
players.push(obj);
playerCount++;
} }
wss.on('connection', (socket) => { wss.on('connection', (socket) => {