Real Time Multiplayer With Construct 2

0 favourites
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • I've been struggling with this for a while and it was the reason I stopped development of my game for 1/2 a year, it got me quite down.

    The game is pretty much all these apart from the multiplayer aspects not working very well.. which is bad, 'cos it's not much of a single player game <img src="{SMILIES_PATH}/icon_razz.gif" alt=":P" title="Razz">.

    Some of you who were around in the 90s might remember Wireplay and the awesome selection of games they had for us to play (on a 56k modem mind). One of those games was Rumble In The Void.

    The game is still available (I think I have a copy of the original or 2 somewhere) to play as single player, but you can never again play it multiplayer.. because you'd need the wicket.vr1 to work... and it only works with a working server that was made for the game.. and none of the code was ever released.

    So I took it upon myself to remake the game in its entirety. I could obviously rip some of the assets from the game such as individual sprites and sounds but that's all I had to go by. By using Construct 2, I took all of the parts of the game and reasembled, making sure to keep the gameplay mechanics and general "feel" of the game as close to the original as I could.

    It took me several months to do in 2014 and I just lost heard when the multiplayer (which was the entire point of the project) just didn't seem to work quite right. Now this is where you can help me!

    Here is the project so far, (http://heiach.wix.com/ritv-remake) you might even see someone else online at the same time as you!

    I put together the rudimentary multiplayer using various tutorials I found on Scirra and Construct 2 forums.. I'm using the socket-io plugin and using Node.js to run the "server" which is really just a glorified notepad file with .js plonked on the end.

    I have a number of problems and I hope you guys can help me get past them so that those of us who adored the games in the 90's can play it together once more, maybe even have tournaments like we once used to!

    I have very little knowledge of coding in javascript or whatever the server is coded in, I've just been putting snippets together and getting intelligent friends to help me get past the various errors that crop up.

    The "server" file I am using can be found here (https://dl.dropboxusercontent.com/u/198 ... erver35.js) if you want to have a look at the mess I've made!

    I used tutorials on how to use the socket-io plugin and took it from the basic program I was supplied with (I think it was 2 ducks shooting eachother?) to what I have now.

    Here are the problems I am currently having:

    (1)

    I'm finding it very hard to get data from each of the clients, but I have sorta managed to do it.

    The way it seems to work is client I have made sends out a burst of information every 0.05 seconds to update all of the clients in the game of the ship position, orientation and what animation frame the ship is using (ie which ship the player is using). Like so:

    http://i.imgur.com/yvAUsFz.png

    I have tested various timings for that and found that if I had it send out the burst at 0.10, the other ships would look choppy to other players, the positions weren't updating fast enough... 0.05 seems to be working okay though (the current version on the website I supplied is using the 0.10 version if you want to see it being choppy).

    If I send out the burst every 0.01 then it just seems to cause a massive backup of all of the information and everything lags and goes out of sync, very, very quickly!

    (2)

    Retaining client information...

    I got a lot of lag if I sent out too much information in the 0.05 bursts, so I put all of the less essential information in a burst that goes out every 2 seconds instead:

    http://i.imgur.com/q7EAdei.png

    The problem is that this information only seems to exist when the burst happens.. and because this burst contains the information about player names (which are displayed next to the ships) everyone's names flash every 2 seconds.

    This leads me on to my 3rd issue..

    (3) Displaying client info

    I'd ideally love to be able to list all of the players that are currently online and also to list the current top scores in the game so we can see who is winning etc...

    But it's hard to do with the information only existing once every 2 seconds.. and even then, I've yet to successfully be able to get the game to be able to translate and display this information...

    Please can you guys help me?

    Edit:

    Oh yeah, I have a 4th problem too.

    (4)

    The bursts don't get received if the client isn't active, ie the browser the game is running in is minimised or if the client program running on the desktop isn't the active one at the time... this means that as soon as the client *does* become active again, all of the signals that they missed suddenly all happen at once, it's like watching a movie in fast-forward.. and this obviously will/does cause a lot of syncing issues too...

  • Also I'm pretty sure this isn't the best way to do things at all.. I mean I don't think I need to tell all of the other clients the x/y position and speed of the ship at all times, surely I can just tell the game that a ship is flying in this direction and this speed and is facing this direction and only update it if that changes (ie the player moves or changes direction/stops the engine).. that would save a lot on sending information.

    Also I'm pretty sure that the way it is working atm isn't the best either.. every player has a client and the server is acting as the bridge between them all, telling every other player what every other player is doing every 0,05 seconds.. it just seems a bit messy and that's a lot of information coming and going at a very fast rate!

    As it is at the moment, the computer that's hosting the server is just running the .js file and not a copy of the game.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Holy heck, apparently Scirra made/is making multiplayer a part of Construct 2? I think so at least, from a post I just read.. I downloaded a more up to date version of C2 (rather than using one from a year+ ago) but it requires a plugin called Multiplayer by Scirra.. and gives no indication as to where to get it from.. and after googling and searching for a while.. no joy.. where do you get this plugin from anyway?

    And even if I use the new mutliplayer features that I believe Construct 2 has implemented, would it be easier to entirely recode my game to try and use these? I mean I'm basically there with what I made a year or so ago using websocket plugins...

  • Could I get some help please?

  • Start with Multiplayer tutorial 1: concepts. The Multiplayer plugin ships with the latest releases of Construct 2.

  • Heiach, we now have a Google discussion group specifically for discussion of C2 multiplayer development -- challenges we face, best practices, comparing different approaches to aspects of C2 multiplayer development, that sort of thing. Any interest in being added on? No obligations to it whatsoever, just a Google group. PM me if you're interested!

  • Ashley I'm not using the multiplayer plugin.. I'm using the websocket.io which was the only thing available at the time I made the game. (Back in 2013/2014)

    Televangelist er sure, I have no idea where I'd have to go to see it but sure!

  • But I do wonder if I've gone at it the right way...

    I did have a brief look at the multiplayer plugin, I connected to the server in the example and it was laggy as all hell.. and if that's what multiplayer is like using that plugin, I'm better off with what I've managed to piece together with snippets of code...

  • Lag depends pretty much entirely on the quality of the connection. I don't think the multiplayer plugin is responsible for that.

  • Yeah, I've tried the multiplayer plugin out with friends on the opposite coast from me (using a couple of different demo games) and it worked nicely with fairly low latency and good prediction.

  • Oh okay, well I'll of course look at that plugin but it would involve redoing everything I've done to try to get it to work with the socket.io etc.. I mean it's like 90% there... There's just the issues with player names flashing and not being constant and also the game playing fast-forward catch-up when you return from minimising the game...

  • Televangelist Can you add me to that group aswell? Can you send me details via PM? Thanks

  • Ashley

    I connected to the server in the example and it was laggy as all hell.. and if that's what multiplayer is like using that plugin, I'm better off with what I've managed to piece together with snippets of code...

    same expirience here...

    (my location is in Europe)

  • It's still entirely the quality of your connection to the host. If you're connecting to some random person who's also in the example, then it also depends on the quality of their connection. Set up your own room to give it a fair test. Otherwise if you are just connecting two random machines on the Internet, it's a lottery whether you get a good result or not. None of this is really anything to do with the C2 multiplayer plugin, it's just how the Internet works.

  • Televangelist

    Thanks

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