Jump to content

Multiplayer Game Rendering Existing Characters in Multiple Rooms


Recommended Posts

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.


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.


Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...