Renderer = new Render("canvas", "./assets/map/map7_recadr.png"); let Net = new Network("ws://129.151.227.50:8080/", Renderer); //let ClientKeyboard = new Keyboard() let playerId = null; //id of client player let players = []; let player = null; Inp = new Input("canvas", Net); playerId=Net.playerId; player=Net.clientPlayer; players=Net.getPlayersToAdd(); let dt = 1; let playerToUpdate; function update() { playerToUpdate = Net.getPlayersToUpdate(); for (let i = 0;i { console.log("New player: ",playersToAdd[0].id); players.push(playersToAdd[0]); Renderer.AddPlayer(p); }); } function remPlayers() { let playerToRemove = Net.getPlayersToRemove(); if(playerToRemove.length==0) return; for(let i=0;i { Renderer.AddPlayer(p) }); } } else { update(); addPlayers(); remPlayers(); player.update(squares, circles, dt); for (var i = players.length - 1; i >= 0; i--) { players[i].update([],[], dt);//squares, circles } Renderer.ReloadAff(); } let newTime = new Date(); dt=newTime - currentTime; currentTime=newTime } Net.connect(); //connect to server, create a player, and retrieve all players info setInterval(game)