Integration with Photon Cloud: Multiplayer

From the Asset Store
This is a simple login feature to access Metamask in construct 3. Requires a Chrome Browser and Metamask Extension.
  • Velojet

    Yep it works ! If you need some help for testing the plugin i'm now properly equiped :)

  • Velojet

    Ok I put the ':9090' and it seems the header txt file is there. but its still not working :p

    SpacialPumpkin

    Where did you put the ':9090'?

  • Velojet

    Right after the master server address (the US one).

  • Right after the master server address (the US one).

    SpacialPumpkin

    But in what file? It doesn't appear in your evantarctica.netau.net/photonclient.workout/cloud-app-info.js.

  • (NOTE: Before trying out the PhotonClient behavior as outlined here, you need to work through my demo as explained in my post of 2 Apr 1:17 am, top of page 11.)

    As promised, here?s my Construct 2 PhotonClient behavior that you can now try adding to your own sprites:

    https://dl.dropbox.com/u/54915877/photonclient.zip - install this in the usual way (sorry, I?ve not yet made it as an add-on).

    Here are the ACEs you can use ? you?ll find examples of the use of each in my Workout demo (whose capx can be downloaded from https://dl.dropbox.com/u/54915877/photon.workout.capx) :

    [Conditions/events]

    • On joined
    • On leaving
    • On web player/s to be created
    • On web player joined
    • On web player updated
    • On web player leaving
    • On collision with another player
    • On impacted by another player
    • On message
    • On game server ready (currently unreliable ? needing the Photon team to add a connect event handler)

    [Actions]

    • Initialise data of web player to create (i.e. data to be used by C2 in creating web players)
    • Set the web player's ID (this pairs the Photon-allocated photonID with the C2-allocated UID)

    [Expressions]

    • WebPlayerX (The current X co-ordinate of the picked web player)
    • WebPlayerY (The current Y co-ordinate of the picked web player)
    • WebPlayerUID (The picked web player's UID)
    • NumWebPlayersToMake (The number of web players to make)
    • WebPlayerPID (The picked web player's Photon ID)
    • Name (of either my player or the picked web player, as selected)

    I?ve liberally commented my Workout demo, and I hope that?ll be sufficient documentation of the use of each of the ACEs.

    The PhotonClient object also has these custom properties that can be set in the usual way, in (where else?) the Properties bar:

    • Auto-repeat: If enabled, the arrow keys (and sprite movements) repeat if held down. Otherwise, keys need to be tapped repeatedly to produce movement. This can make it easier to control positioning.
    • Tiled: If enabled, sprites move from tile to tile rather than pixel by pixel (see my comment below).
    • Tile size: Length (in pixels) of tile side (default is 32).
    • Random start: If enabled, my player starts in a randomly chosen vacant position (see my further comment below).

    ]] More about the ?Tiled? property: As with most multiplayer games, latency is a problem. It can result in jerky pixel-by-pixel movement. One simple way of dealing with it is to make big movements of sprites from tile to tile, rather than attempt smooth movements pixel by pixel. That?s why my Workout demo uses tile-by-tile movements.

    ]] More about the ?Random start? property: When enabled, a random initial position is chosen for your player and (most importantly) if there already happens to be a web player in that position, another position is chosen and checked, and so on, until a vacant position is found. Otherwise it?s up to you to choose the starting position, and to provide for the possibility of an initial collision.

    Some things to note:

    ]] You need to use the ?Export project? (as a HTML5 website) option ? ?Preview will give you an error (try it!).

    ]] Don?t run the export through the minifier ? there?re still some kinks to be ironed out before it?ll meet the exacting requirements of the Google Closure Compiler.

    ]] The player name input, the ?Join? and ?Leave? buttons, and the header (?= Construct 2 <-> Photon Cloud multiplayer =?) are created before the C2 runtime kicks in. They can be styled in the photon_client-inputs.css file in the photon.workout/css folder, and the header can be changed by editing the inputs_header.txt file in the photon.workout folder.

    ]] The Photon Cloud allows for multiple rooms in a game lobby. At this stage, I?ve not attempted to implement that feature and my PhotonClient behavior accesses a single room (called ?C2demo?).

  • Thank you so much ! Can't wait to work on a multiplayer game !

  • Nice one velojet!

    Haven't tried it yet, but do you think real-time (non-tile) movements will be possible in the future, or latency issues would be just impossible to sort out, or you need to wait for udp support or something like that?

  • Velojet

    Ok I put the 9090 in a different cloud file, the one in my dropbox. It should have the 9090 in my http server file now. Thanks for making this plugin and helping me :)

  • lemo

    Thanks! I'm sure it will be possible for RT HTML5 apps to support smooth pixel-by-pixel motion. And UDP will be part of the solution. Interestingly, the Photon Cloud supports UDP. The documentation says "You can even customize the way of exchanging information by specifying a protocol (UDP vs. TCP or reliable UDP vs. unreliable UDP) with simple parameters, depending on your needs", but AFAIK, the JavaScript SDK doesn't (yet) offer this customisation.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Awesome! I can't wait to try out.

  • ... If you need some help for testing the plugin i'm now properly equiped :)Joskin   Thanks for your offer! I'm keen to have people using it to make a MP game for themselves - and to tell me what needs changing and adding.

    Taurian   Great to have you checking in here! I'd really like to know how far it goes towards meeting your expectations.

  • Hi!

    I am extremely excited about this photon plugin. I just registered and am about to do the tutorial. I have a few questions though. I have a hostgator account. And I have a domain name hosted on hostgator. I also know how to upload files to them. Do I upload the workout capx in the ftp part? What should I put in there?

    Amazing work!

  • AarongamerX

    See my post of 2 Apr 1:17 am, top of page 11 - it explains what files you need to upload to your HostGator account, to get my Workout demo working.

    When it comes to making your own game, it's the files produced by the C2 HTML5 exporter that you'll need to upload + your edited cloud-app-info.js file.

    Thanks for your positive feedback!

  • I completed all the steps :D <img src="smileys/smiley32.gif" border="0" align="middle" />

    The only problem is when I play, player 2 doesn't show up. I tried my sisters computer and the room was empty. I copied the ID and region code in the js file but no luck. I went ahead and uploaded the cloud-info js file to my server. Not sure if that's needed.

    You said to re-save removing the template part but what are we supposed to do with the file? And What would cause the server not to work?

    I am so close....I know it hehe.

    Thanks.

  • ... You said to re-save removing the template part but what are we supposed to do with the file? ...

    AarongamerX

    Well, if you resave your edited cloud-app-info.js file, it'll end up the same folder on your HTTP server as the one where you've copied your Workout demo files (in my example, that folder is called photonclient.workout). You don't need to do anything more with it.

    Give me the URL of your copy of the Workout demo, so I can take a look.

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