Integration with Photon Cloud: Multiplayer

Discuss game development design and post your game ideas

Post » Mon Jun 18, 2012 8:25 pm

[QUOTE=Yung] Keep up the good work! If its not too much, could you share with us a video of that in action? [/QUOTE]
I'll post a capx when I've got something worth sharing ...
B
105
S
20
G
12
Posts: 549
Reputation: 20,320

Post » Sat Jun 23, 2012 5:56 am

Update: I now have more than just a stub plugin in a simple C2 constructed 20x15 grid.

What I've now got is a PhotonPlayer plugin that's a modified Sprite plugin (ideally, it would be a PhotonPlayer behavior that could be added to a Sprite).

It dynamically loads the PhotonPeer.Lite JavaScript interface to the Photon server running locally, draws the PhotonPlayer sprite on the screen (movable by arrow keys) and sets up buttons for 'connect', 'join', 'disconnect', 'leave' actions, which enable it to join a game in a game lobby. That bit works.

To do next (the real multiplayer bit): enhance the plugin to send a PhotonPlayer's position via the server to another C2 grid in another browser and have it appear and move there (along with the local PhotonPlayer object), and vice versa.

Questions/suggestions welcome!Velojet2012-06-23 06:35:12
B
105
S
20
G
12
Posts: 549
Reputation: 20,320

Post » Sat Jun 23, 2012 4:51 pm

That's awesome news. For the Socket IO plugin I send Comma Separated data. But I know the photon server uses Op Codes. We send data on a specific channel with certain parameters etc. Let me know if any of this rings a bell.
Epic Space Online - Google it!
B
34
S
10
G
5
Posts: 165
Reputation: 6,637

Post » Sat Jun 23, 2012 10:10 pm

@Taurian
Thanks very much for your encouraging reply.

Yes, your reference to Op Codes does ring a bell. I'll be using PhotonPeer.Lite.raiseEvent (eventCode, data ) to send the player's position to the server. I see the Photon JDK documentation says that its parameters are:
- eventCode <Byte>   The event code (I guess this is the Op Code you refer to)
- data <Object> A JSON object with the event data (so it uses JSON rather than CSV, as you mention the Socket IO plugin does).

I'll certainly get back to you if I hit a snag.Velojet2012-06-23 22:11:35
B
105
S
20
G
12
Posts: 549
Reputation: 20,320

Post » Fri Jun 29, 2012 8:26 am

Update: Well, I've actually now got a working experimental PhotonPlayer multiplayer plugin for Construct 2. Here's a tantalising unfaked screenshot:


... and here's the C2 event sheet:


Yes, that's really all there is.

I've got quite a bit of tidying up to do over the coming week, before the code's fit for public viewing. After that, I plan on releasing it as an experimental plugin for playing around with and giving me feedback.

As you can see from the browsers screenshot, I have it running on localhost (WAMP server) - not yet the Photon Cloud, which was Taurian's original challenge.

Watch this space!
B
105
S
20
G
12
Posts: 549
Reputation: 20,320

Post » Fri Jun 29, 2012 4:04 pm

[QUOTE=Velojet] which was Taurian's original challenge.

Watch this space![/QUOTE]

Yeah well beggars can't be choosers. Can't wait to give it a shot. Amazing work Velojet!
Epic Space Online - Google it!
B
34
S
10
G
5
Posts: 165
Reputation: 6,637

Post » Fri Jul 06, 2012 11:56 pm

Awesome work, I look forward to experimenting with this.
B
5
G
2
Posts: 6
Reputation: 1,277

Post » Sat Jul 07, 2012 10:01 am

[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 scriptsDir 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

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! Velojet2013-04-04 09:38:52
B
105
S
20
G
12
Posts: 549
Reputation: 20,320

Post » Sun Jul 08, 2012 5:44 pm

I'm new here, so I'm not sure about my posting boundaries, but I would love to just interject that I am very excited for the streamlining of the multiplayer aspect for Construct 2. I began doing the outlining on my first big project and it turns out that it may rely heavily on multiplayer and it will be worlds better if it can be more than just local. Everywhere I have looked for real info on Construct 2 and Multiplayer has wound me back to Taurian's work, so a special thanks to him. I'm looking forward to seeing the knots hammered out of the deal and implemented into a future update. This was the make/break decision that will have me developing for Construct.
B
6
Posts: 8
Reputation: 716

Post » Sun Jul 08, 2012 8:07 pm

@Stercus
Thanks for your positive feedback!

Try out my multiplayer PhotonPlayer and let's know what knots need hammering out! Velojet2012-07-08 20:10:51
B
105
S
20
G
12
Posts: 549
Reputation: 20,320

PreviousNext

Return to Game Development, Design & Ideas

Who is online

Users browsing this forum: cristobal and 1 guest