Yet-another Multiplayer Demo (with capx)

0 favourites
From the Asset Store
Simple yet very life-like rag doll made with Physics!
  • I am gonna Re-Install NodeJS and Step By Step go through it

  • It works now :)

    I created the node_modules folder again. And NPM install socket.io inside it with a Admin CMD. thx thx

  • It works now :) ...thx thx

    HTH <img src="smileys/smiley1.gif" border="0" align="middle" />

  • This confuses me a lot!

    When is the Array Assigned?

    <img src="http://imageshack.us/a/img338/1745/arrayquestion.png" border="0" />

  • hi. I have the game and connected and everything but I have a problem from a remote website to move a sprite until it dies but it updates the other page you can help me

  • Schoening : it gets set when C2 receives an I (initialization) or a C (create another player). Basically it gets assigned when a new player gets created (including the player that "owns" the current game instance.

    That array just holds the UID of the players' sprites to allow picking them when a network event arrives affecting them.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you :)

    And the Array int(Socket.LastDataElement(1)) does not get overwritten because it uses the variable myNumber = count++; on int(Socket.LastDataElement(1))?

  • Schoening Exactly. The server script takes care of incrementing the player id every time a new player joins.

    The "Array int(Socket.LastDataElement(1))" part is basicaly saying:

    1. get the affected player id number from the message we receive from the server. In the sample, the messages always put the player id in the second position of the message, that is why you need to get the element from the last data that resides in index 1 in the internal message array. The first position is the type of message.

    2. Once the number if obtained, convert it to an int. This is because the raw network message is of text type.

    3. Once the affected player id is converted to an int, use that number to lookup the UUID of the sprite that belongs to that player.

  • If the server runs for a extended period of time. Won't the count++ array get massive?

  • Is it supposed to stay stuck like this?

    <img src="http://dl.dropbox.com/u/61808535/socketio.png" border="0" />

    And now the multiplayer in the example isn't working...

  • InvaderX

    Yes!

    That means the Socket.io is running and waiting for input :)

  • But when I run the preview of the example capx, it doesn't connect.

  • Schoening : yes, sort of. The count variable it would get massive if there is a massive amount of players joining. The count variable gets incremented only when a new player joins so that the server can assign a unique number to that player.

    The server script in the sample was not designed to be run forever. It works more like the old games: you would start the server part of the game every time you wanted to play a multiplayer game, let you friends know about the IP address of your game session and then close it when you were done with the match.

  • But when I run the preview of the example capx, it doesn't connect.

    Tell us what going on. <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Schoening : yes, sort of. The count variable it would get massive if there is a massive amount of players joining. The count variable gets incremented only when a new player joins so that the server can assign a unique number to that player.

    The server script in the sample was not designed to be run forever. It works more like the old games: you would start the server part of the game every time you wanted to play a multiplayer game, let you friends know about the IP address of your game session and then close it when you were done with the match.

    It really helped me getting started on learning ServerSide JavaScript thank you very much !

    For my use I will probably try to find a way to reuse the array in places where a player has left.

    Like perhaps using This this, as a reference, and moving the players closer to 0 when some one leaves ^^

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)