Integration with Photon Cloud: Multiplayer

Discuss game development design and post your game ideas

Post » Wed Apr 03, 2013 12:52 pm

Velo , is the plugin out ?
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Wed Apr 03, 2013 5:47 pm

@Velojet

Yep it works ! If you need some help for testing the plugin i'm now properly equiped :)
B
39
S
15
G
5
Posts: 295
Reputation: 6,089

Post » Wed Apr 03, 2013 6:50 pm

[QUOTE=SpacialPumpkin] @Velojet

Ok I put the ':9090' and it seems the header txt file is there. but its still not working :p[/QUOTE]
@SpacialPumpkin
Where did you put the ':9090'?
B
105
S
20
G
12
Posts: 549
Reputation: 20,320

Post » Wed Apr 03, 2013 7:44 pm

@Velojet

Right after the master server address (the US one).
B
12
S
2
G
2
Posts: 62
Reputation: 1,567

Post » Wed Apr 03, 2013 7:56 pm

[QUOTE=SpacialPumpkin]Right after the master server address (the US one).[/QUOTE]
@SpacialPumpkin
But in what file? It doesn't appear in your http://evantarctica.netau.net/photonclient.workout/cloud-app-info.js.
B
105
S
20
G
12
Posts: 549
Reputation: 20,320

Post » Wed Apr 03, 2013 7:58 pm

(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, heres 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, Ive not yet made it as an add-on).

Here are the ACEs you can use youll 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)

Ive liberally commented my Workout demo, and I hope thatll 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. Thats 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 its 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!).

]] Dont run the export through the minifier therere still some kinks to be ironed out before itll 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, Ive not attempted to implement that feature and my PhotonClient behavior accesses a single room (called C2demo).Velojet2013-04-06 19:17:14
B
105
S
20
G
12
Posts: 549
Reputation: 20,320

Post » Wed Apr 03, 2013 9:25 pm

Thank you so much ! Can't wait to work on a multiplayer game !
B
39
S
15
G
5
Posts: 295
Reputation: 6,089

Post » Wed Apr 03, 2013 10:03 pm

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?
B
20
S
5
G
8
Posts: 325
Reputation: 6,473

Post » Thu Apr 04, 2013 12:09 am

@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 :)
B
12
S
2
G
2
Posts: 62
Reputation: 1,567

Post » Thu Apr 04, 2013 2:11 am

@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.
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: No registered users and 0 guests