Enternode's Forum Posts

  • 11 posts
  • It's just a websocket server; if you wanted you could use Node.js/Flask/RubyOnRails/Etc to make a basic webserver to support websockets (via something like socket.io); plenty of tutorials exist on how to do this with your language of choice, then use a cloud service to host it. It would be yours, under your full control, and so long as you deploy it correctly, you'd have no problems with using a low power, cheap host for a good couple hundred plus clients.

    I don't want to go into detail about how to do this, though - that might be a bit too tangential.

    If you want a no-code solution, you're much more limited; please keep in mind that WebRTC is a peer-to-peer solution, which means that if security is a concern, I would avoid this. The same can be said for that signalling server Sircca is selling. But, if you have no need for a central database/server and you are not conveying any sensitive information, it can be a cheaper and lower-hassle solution.

  • You can use the condition Contains Value to see if a value is in an array

    You can also use a For Each Element condition and use a sub-event if you wanna do this for all values (where the expression CurValue is the current element in the looping array)

    No easier way to do this that I know of

  • A solution you may want to try is to store an "in air" timer as either a global variable or an instance variable of the player sprite (I recommend the latter). Have one event test if the player is in the air, and if so, increment it by one (via the Is On Floor condition, just invert it), and if not, set it to zero. If the player presses the jump key while the sprite is in the air, and the timer is below a certain value, have the player jump.

    What you may also do is to enable double-jumping, and then use the Reset Double Jump action to disable it after the player was in the air for long enough. That way, you can just use the built in jump command, as simply using simulate control while the user is in the air won't work with double-jump off.

  • You should check out the documentation for the Array type as a reference.

    How you want to compare them is dependent on how you intend the game logic to work (which you didn't specify), but the Compare At X condition will let you select one array at a given position. You can then use the Array.At(X) expression to select the other array you want to compare.

    If you want to know the number of elements in a given array, you can use the Array.Width expression and use some system comparison condition to compare it with some value.

    Hope this helps.

  • Just to clarify, is what you want for the character to jump every time it leaves the ground, no matter what the reason for it was?

    If this isn't correct, under what circumstances should they jump?

  • ...oh, small bump by the way: I should mention that any code attempting to grab a cookie being ran in preview won't actually work - you'd need to deploy it to the site itself in order to test it. Otherwise, there's no cookie to grab, because the preview is running on Construct's website and not your own.

    I suppose for testing purposes you could try implementing the login form within construct and store the token as a cookie or in session data, then try to grab it using a different script, but you'd need to configure CORS on your webserver for that to be possible.

    It's tricky, and I'm sure what we're doing here was never intended by the developers of construct; this wouldn't work at all on a mobile deployment, only HTML5.

  • My model has the game all under Construct with the back end being mostly JSON APIs and sockets, so I haven't needed to do this, nor have I tried, but it's probably possible; I just don't know how off the top of my head. If I find something out I'll post it here.

  • I need a way to send the player's username & password from my website to the game after they login.

    What you are looking for is an authentication token. Your question isn't actually all that different from mine, actually: construct.net/en/forum/construct-3/how-do-i-8/user-authentication-custom-157301

    If you log in and store the token on the website, it should be accessible as a cookie, assuming the game's page is also within that same website; you can use JavaScript to grab it most likely, then just store it as a global variable.

    And just to also drive this point home too...

    User authentication is an extremely tricky subject, though I agree that using cookies and session data within Construct 3 is not easy because no tools are provided to do so without the use of Javascript.

  • construct.net/en/forum/construct-2/beginners-questions-19/zuma-game-77688

    Nobody's going to do all the hard work for you, unfortunately.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So I have done some research and theorizing. Don't mark this as answered just yet, but the best solution would probably be to use a JSON Web Token for this using a utility like flask-jwt-extended.

    • The server keeps a secret key
    • A user wishing to "log in" sends the credentials to the server using an HTTP POST method and a JSON payload
    • If all factors of authentication pass, the server signs an authentication token and sends it to the client.
    • The token is then passed in the header of any subsequent HTTP requests.

    This is something similar to what OAuth does; the token itself can even have a payload of information to be stored, like the username of the user, or a machine identifier, for further verification and security (and to reject invalid tokens). It can either be stored in a temporary global variable or even stored in LocalStorage.

    I'm leaving this open to debate in case I missed anything, or there's a better way; I want to stay away from any model that involves the client directly querying the database, so I want to avoid Firebase as much as possible.

  • This is much more of a technical/theoretical question than a "I have a bug please help me" question, but it's a rather important one to ask because when dealing with a user's account credentials, it's important to get it right the first time. TL;DR at the bottom, but here I'll describe my specific use case. I don't currently have a project file.

    I have a custom webserver made in Flask that will handle multiplayer. It's using websockets via socket.io, but since the game is non-realtime, it's the most appropriate. It's inevitable that I will have to have user accounts involved; I can't avoid it, so this webserver will handle user authentication in a local database. And yes, I'm not completely irresponsible with this. This Flask server will also handle lobbies and game logic.

    I want to have Construct handle the front end/client side of things. It's fairly elementary to have Construct handle socket events and HTTP requests via the AJAX and Socket plugins, but things become complicated when it comes to user sessions; an HTTP POST request to the server will almost certainly return and keep the login token and the information about the user (username/etc) in the session data, and for "remember me" functionality, cookies. It doesn't really seem like I can access that, though, nor can I really guarantee that all platforms will support it.

    Am I missing something? Is it actually the case that Construct will use cookies/sessions just fine? Is it maybe just the case that I can't actually access them? For the web version of the game, it will be the case that the web server will return the game from an HTTP GET request to the web server's URL, so the cookies should still be valid for that site, but this wouldn't really be the case for previewing the game within Construct, nor would that (probably) work for deployments of other platforms (due to the nature of the game, though, mobile app support is expendable). Surely, I'm missing something; I know of the Firebase plugin people usually use, but since I'm hosting the server side logic from a webserver, using an external database would be a bigger liability than is really worth, ESPECIALLY implemented in the way the Firebase app is (remember, no logic on the client side; client should not be allowed to query the database at all).

    I'm fully able to have the user authentication on the server side work pretty much however is needed, but I most certainly want to do so in the most responsible way possible. Having a POST request over HTTPS would most likely be the most easy and secure way of doing it (because doing that over sockets sounds like a really, really bad idea), but it's something that's just tricky to get right.

    I appreciate any feedback for a rather... complex and out-there first post question.

    TL;DR: What's the best way to handle user authentication and login sessions for a game with a central server (as opposed to Construct-style P2P) and database?

    p.s.: Happy Holidays!~

    Tagged:

  • 11 posts