Answer the question
In order to leave comments, you need to log in
How to implement game rooms in the game?
Now I have a 2D tds browser shooter. On the node server, for physics I use the 2D MatterJs engine. Now simple mechanics have been implemented: synchronization of player movements, shooting, magazine.
At the moment, the server code has the following structure:
var gameObjects={players:{},walls:{},bases:{}}; // здесь хранится инфа о игроках и других объектах
// launch game cycle
setInterval(function(){
Matter.Engine.update(engine, engine.timing.delta); //обновление физики
},1000/60)
io.on('connection', function (socket) {
socket.player=createPlayer(socket);
socket.on("....",function(){});
socket.on("....",function(data){});
socket.on("....",function(data){});
socket.on("....",function(data){});
socket.on("....",function(data){});
socket.on("....",function(data){});
});
var rooms=[
{players:{},walls:{},bases:{},engine:setInterval(...,1000/60)},
{players:{},walls:{},bases:{},engine:setInterval(...,1000/60)},
{players:{},walls:{},bases:{},engine:setInterval(...,1000/60)}
]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question