[EDIT 4 April 2013:
PLEASE NOTE: My Dropbox files in this message are no longer available. They're superseded by the
PhotonClient behavior that I've now released.]
OK. Here's the alpha version of my PhotonPlayer multiplayer plugin:
PhotonPlayer
Be warned that, as an alpha version, it's quite rudimentary. But it does implement the essential multiplayer functionality: it allows you to run the same (grid-based) game in a second locally-hosted browser window and see the first browser's player moving around the grid in real time.
What it doesn't let you do at this stage is:
- have more than two players, each in their own browser window
- have any sort of interaction between the two players.
So it's basically just a proof of concept at this stage, which is why I'm not yet announcing an official release in the 'Plugins for Construct 2' forum.
To see it in action, you'll need a HTTP web server running on localhost (I use WAMP server, but you may prefer XAMPP or plain Apache or IIS ...). Set up a folder on that web server from which to serve games that use the PhotonPlayer plugin.
Change the <font face="Courier New, Courier, mono">scriptsDir</font> variable in the PhotonPlayer plugin runtime.js (line 34) to point to that folder.
(You may like to check out the rest of the code - hopefully, I've put enough comments in there for it to make sense to anyone who knows JavaScript and Photon.)
Next, download and install the Photon 3 server SDK to run on localhost (port 9090), together with a free license (here's help).
You'll also need to download and install the Photon JavaScript SDK: Photon-JavaScript_v-3-0-0-3-Beta_SDK.zip - there's an INSTALL.txt file in the package.
Now take this capx of a demo 'game':
PhotoDemo
You can preview it in Construct 2, but you won't see its multiplayer character until you export it (don't minify it) and install the resulting files (c2runtime.js, index.html, ...) in the folder you've set up for it on your web server.
Now fire up your web server.
Start Photon Control as an application.
Open a browser (either Firefox or Chrome) and access the localhost address where you installed PhotonDemo (with its c2runtime.js and index.html) (for me, the address is localhost/dev/photon). You should see a screen similar to the one in my screenshot above (my post of 29 June).
Click the 'join' button. Open a second browser, give another nickname to your second player and click 'join'.
Move your first player and you should see it also move in the second window. Move your second player and you should see it also move in the first window. You're multiplaying with Construct 2!
-------------------
The PhotonPlayer edittime is just a duplicate of the Sprite edittime at this stage. Obviously, it needs some added actions, conditions and expressions (ACEs) e.g. to be able to check the positions of remote players. Those ACEs will be added in due course, but not for a week or so, yet. Next week, my Construct 2 time is going to be spent on trying to throw together a competition video <img src="smileys/smiley2.gif" border="0" align="middle">
In the meatime, please feel free to ask questions. And of course, I'd welcome any comments you might have.
And a BIG THANKS to Taurian for putting me onto Photon! <img src="smileys/smiley20.gif" border="0" align="middle">