Yet-another Multiplayer Demo (with capx)

0 favourites
From the Asset Store
Demo Game Multiplayer Online with member registration system
  • Hi there!

    I cannot open the project with the last stable release (r95), it says:

    "Could not open project. Cannot find condition by ID"

    , is it possible I'm doing something very wrong or that there is some incompatibility?

    Thanks!

    Rahms

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi!

    First of all, thanks for the great job. I got the server started, but i cannot open the .capx file. Same problem as rahms above. I got the latest update too (Release 95) Is it possible you could make a .capx file in the new version?

    /Michael

  • I put a new version that I tested succesfully with r99. Also, when extracting the plugin make sure the files are directly in the socket-io-mod folder in the plugins folder, in other words you should see a runtime.js dated today in plugins\socket-io-mod. Previous versions of this plugin might have dumped the files into a folder named "socket-io", if you have that folder, delete it.

    Also, if you see any old files with "(Picture-That)" in their names, you need to delete those. Those were backup copies included by accident in the previous version.

  • hello, I have installed the node.js and am reviewing the example you left, is very good, but wanted to ask if "Controller" is a plugin where I can find that if I can do that only two players are playing and at time and if I can remove a player if you enter another, thanks for this tutorial and look at this super blog and also helped me clear my good a couple of questions I had thanks

  • itza3985

    No, Controller is not a plugin. It is just an empty TiledBackground object that I use to hold some variables related to controlling the networking logic.

    If I understand the rest of your post correctly, you want to allow only 2 players at all times. You also want to "kick out" one player when another connects. There is probably a way of doing that, and the best place to put the logic is in the Node script (example_server.js) somewhere after "//assign number", a high level overview of the code would be:

    1. call disconnect in one of the players

    2. change the line that increments the myNumber variable to increment only if the number of players is less than 2.

    Right now, the example just allows any number of clients to connect.

  • Thank you. I've been thinking about it.

    actually I want to do is to show me on a TV connected to a pc game and use another device as a control. think it's possible and how it could do. that's why I thought that the PC that is connected to the TV could be a player but will have no involvement but I'm still looking how to do that, if you have any idea can help me

  • itza3985 so do you want the game to show in a TV that is connected to the PC but have the controller for the game a spearate device (like an Iphone)?

    If that is the case, you could just connect an hdmi cable from your pc to the TV (if your TV supports it) and just set up Windows to output to the TV.

    As for the iphone as the game controller, you could create a separate C2 "game" that just shows arrows in the screen. Every time the user clicks the arrows, you can have the socket plugin send a message to the server running in the PC (a node.js script). Once the server running in the pc receives the message, you can have the server script send the message to the C2 game running in the PC. In that game you can just put a logic that says something like if the message from the socket starts with "L" then simulate a LeftArrow.

  • i've been following your work for some time now, and your example really inspired me a lot to start digging deeper in Construct and multiplayer stuff.

    I'm a kinda self-taught guy with highschool/college/bussines experience in bunch of different languages (starting in '97 with some good 'ole qbasic and GOTO 10, GOTO 20 stuff), but javascript and node really got my boner up, if you now what i mean, so take my words with a grain of salt.

    So, after reading some of your code on server example, and zack's socket.io plugin and some hacking with it i realized that if we have just a "send" action which calls Socket.send(data), server will always be a giant if loop, and we'll check messages by splitting received data first, then checking how the first part of your message looks like, and i believe it's not really node-ish to do, because when you start writing some bigger pieces your server code is a giant if(like this sentence), which is constantly evaluated and eventually will be slow(er) and hard to understand.

    So i added a "emit" action to the plugin you can emit a custom event to the server. In C2 it is similar to "send", but besides your message, you have to tell it what event are you emitting. Plugin now uses socket.emit('yourevent',"yourdata").

    Now server can, instead of looking like this:

    socket.on("message", function (data) {

        var new_data = data.split(',');

        if (new_data[0] == 'P') {do something}

          else if (new_data[0] == 'D') {do this}

          else if (new_data[0] == 'L') {do that}

    etc...

    look like

    socket.on("message", function (data) {

        var new_data = data.split(',');

        etc

    }

    socket.on("yourevent", function (data) {

        var new_data = data.split(',');

        etc

    }

    and I believe it's much more elegant.

    I planned to post my plugin now, but i've found out you released an updated version few days ago so i'll incorporate my edits to your latest version, and put it here so you can check the code and see have i fucked up anywhere.

    I also started to hack the plugin so you can trigger custom events inside the plugin (so that server can emit custom events to client), but thats a work in progress.

    itza3985: Actually all this motivation for adding emit function is because we're currently working on something similar to your idea. (By we i mean group of 4 people working on this for last 3 months)

    Whole system is made with idea that is reusable for different kind of games, so everyone will be able to connect to our server and implement joystick functionality to your C2 projects. Server is currently hosted on nodejitsu, in my opinion the best Paas currently online (give them a click: http://nodejitsu.com/

    I hope to share a demo with you within next 3 weeks (it's online, but we won't share it until it's on some decent level)

    Taurian with "emit" action you'll be able to utilize the room thingy(although you can do it now with "send" also), but it's something you'll have to do on server side, if i'm wrong somebody correct me, give me some guidance and i'll try to incorporate it in the plugin

    Whoa, enough for now, wrote too much, will report soon with edited plugin and more info on the joystick thingy.

    P.s Has anyone looked into the whole "Socket.io plugin won't minify" thing? In my opinion it's really important to have that problem solved, after i'm done with "emit" thing i'll try put my focus on that!

  • Hi!

    I've added some functionality to socket.io plugin, but please don't use this plugin in production code because it isn't tested, verified, and i'm not even sure that it's in strict ECMA (i've done my best, but it's been a really long night)

    So, before anything, please somebody double-checks this code, for our own safety.

    That said, i've added two new conditions:

    OnEventReceived

    • triggered when your custom event you specified is received

    and

    OnAnyEvent

    • trigered when any event is received (including connect, message, disconect, your custom events etc... )

    one new action:

    Emit

    • emit a custom event through socket. (You must specify which event, and what data to send with that event)

    and one expression:

    LastSocketEvent

    -where you can get last event that was triggered.

    You can check out the great mind-blowing unbelievable test demo with a node server hosted at http://csocket.jit.su/ at:

    https://dl.dropbox.com/u/62601881/csocket/index.html

    and download a zip file with modifed plugin here:

    https://dl.dropbox.com/u/62601881/demo_test.zip

    along with simple example server, package.json and a .capx file in a separate folder.

    Once again:

    I haven't checked is this mod backward compatibile, ECMA strict, or anything, try it, mod it, if you have time, make it better.

    Use at your own risk.

  • JohnnySheffield awesome job Johnny! I was thinking on using custim events as well in the future. You are right about making the server and client code cleaner. I will try out your plugin when I get a chance this week.

    Again, thanks for contributing your work to the community

  • //warning: insomnia rant:

    it nothing compared how much i learned from the community, and socket.io is one of plugins really important and powerful plugins to make construct even more powerful, so i think it's crucial to have it clean and stable as much as possible, and make some pre-made ready-to-use node.js server for the community to use. i think that with good semi-moderate but usable node.js servers on some clouds with good explanations and tutorials will boost the use and knowledge within harmony between construct and node.js and current multiplayer demos/real time usage.

    If you asked me yesterday how constructs plugins are made, i wouldn't had an answer, i spent all my free time in last few months to learn node.js and socket.io and etc, and reading this thread yesterday really inspired me to dive in and stop thinking about modding the plugin and just doing it. It was a really a meditative experience, a lot of barriers was passed last night. For somebody maybe not a great success but for me definitively a level up and a big sense of pride for making this mod.

    // serious question:

    oh, before i forget, let me repeat my question for everybody using socket.io plugins:

    whats your knowledge on why socket.io won't minify?

    Let solve that thing, i believe it would be a great step forward in making this plugin and a yet another great multiplayer demo as neat as possible!

  • Hi Juantar, I'm fairly new to this scene, but I was checking out your plugin and when getting things installed I keep running into the same error in Node.js.

    When trying to "node example_server.js"

    I receive the following errors:

    <img src="http://i.imgur.com/1FsnN.jpg" border="0" />

    Hopefully you can help me out! I'm new to a lot of this socket stuff, but am very interested in getting a multiplayer game working

  • I got everything working and set it up properly, but now I'm wondering how to get rid of characters/avatars/people (The people you play as) when you leave. Because they just stay there and it's quite annoying. Any suggestions?

  • Use the socket.on disconnect function to broadcast it.

  • Just finished the reading and I'm very excited about all of the progress that's being made here!

    I've been spending a good chunk of my day investigating potential multiplayer implementations in C2, and this appears to be the only one that is really making any progress so far as I can tell.

    Outstanding work, from what I can tell, thus far! I look forward to following the progress made here!

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