Search the Community
Showing results for tags 'multiplayer rooms rendering'.
-
Hey guys, I'm building a multiplayer art game which involves multiple rooms. I'm using Phaser for the pixel manipulation stuff, and express/node with sockets for the back end/front end communication. Currently: The server has a players object which keeps track of all the connected players and their positions/rooms. The client has an object for each Level, which contains all the information about remote players. At present they are currently doing their job correctly, as the server and clients seem to know about where the players are at any moment in time. The Problem: When a player enters a new map, I cannot figure out how to render all the remote Players that are already present in that room. Note that it works fine when you are inside a room, and somebody enters your room : You can see them, and they can't see you. This is the information about remote players that is available to the client when they enter the viewing room (in an object called viewingPlayers). This is what the 'remoteplayer' class looks like. This class is essentially an animated facade of another player. var RemotePlayer = function (id, game, player, startX, startY) { var x = startX; var y = startY; this.game = game; this.alive = true; this.player = game.add.sprite(x, y, 'dude'); this.id = id; //animations here this.lastPosition = { x: x, y: y };};this remote player has an update function, that is called in the update cycle of the client. RemotePlayer.prototype.update = function() { //animations go here this.lastPosition.x = this.player.x; this.lastPosition.y = this.player.y;};What exactly is necessary for an object containing several 'remote player' sprites to be rendered to the screen? As long as remotePlayer.alive is true, the remote players 'last position' is updated like this: for (var id in viewingPlayers) { if (viewingPlayers[id].alive) viewingPlayers[id].update(); }Does anyone have any ideas about what I am missing? Here is the github code: (https://github.com/sdlovecraft/virtual-gallery). I believe the problem is isolated in the /public/js/viewing1.js file: where the remotePlayers Obj (viewingPlayers) is failing to be rendered. Any help on this would be greatly, greatly appreciated.
-
Hey guys, I'm building a multiplayer art game which involves multiple rooms. I'm using Phaser for the pixel manipulation stuff, and express/node with sockets for the back end/front end communication. Currently: The server has a players object which keeps track of all the connected players and their positions/rooms. The client has an object for each Level, which contains all the information about remote players. At present they are currently doing their job correctly, as the server and clients seem to know about where the players are at any moment in time. The Problem: When a player enters a new map, I cannot figure out how to render all the remote Players that are already present in that room. Here is a photograph of the information that is available to the client when they enter a room. As you can see there is a class which I have created called a remote player. This is what the 'remoteplayer' class looks like. This class is essentially an animated facade of another player. var RemotePlayer = function (id, game, player, startX, startY) { var x = startX; var y = startY; this.game = game; this.alive = true; this.player = game.add.sprite(x, y, 'dude'); this.id = id; this.lastPosition = { x: x, y: y };};this remote player has an update function, that is called in the update cycle of the client. RemotePlayer.prototype.update = function() { //animations go here this.lastPosition.x = this.player.x; this.lastPosition.y = this.player.y;};What exactly is necessary for something to be rendered to the screen in Phaser? Does anyone have any ideas as to why this might be happening? I have the code available on github (https://github.com/sdlovecraft/virtual-gallery) , if anyone is interested . The problem is likely isolated to be in the /public/js/viewing1.js on how the remotePlayers information, is failing to be rendered in the create() function. Any help on this would be greatly, greatly appreciated.