I've been browsing this site and the web for answer but cannot find any that really satisfies me.
I'm planing to code a small multiplayer web game based on node.js + socket.io for the back-end. For handling new user I coded this:
io.sockets.on('connection', function(socket)
{
socket.emit('connected', {message: "you are connected!"});
var player = new myGame();
}
myGame is a function of my own containing many variables for the game itself (user name, score, money...). My question is how can I have a game engine using data from all the players myGame objects and updating it ? I was thinking of using a global array of myGame objects but then it means that the data is copied twice (in the socket and in the global array).
In C/C++ I would have used pointers or references but JS is a pass-by-value language. Any idea ?