Fengist's Recent Forum Activity

  • Woops, Ashley beat me to it.

    Run the first instance by running preview. Then, hold ALT and run a second preview.

  • Fengist brother, how to set up automatic backup in browser???

    It's in the main menu under settings, save & backup / periodically back up active project. You can set it to backup to the cloud but, like you, it takes a good while to back mine up so I tell it to backup to the browser every 10 minutes which is much faster.

  • I'm going to seriously recommend you set automatic backups to the browser as well. I work on two different computers and save to the cloud as well. Yesterday, both failed to download and run my project. Fortunately, I went to the one I worked on last and loaded the local backup and only lost a couple lines of code.

  • Thanks for the input guys. Obviously I have a bit of homework to do.

  • I recall a few years back digging through the files for Eve Online. One file I found was thousands of lines of text and it was all the credits given for the libraries they used to create their code. Much of the music in the game when it first came out was also a case of being public domain licenses. Any time you can use a free resource without compromising your standards, why not? Locating resources like that isn't difficult. Audionautix.com has some great music that you can use. And YouTube has music and sound effects you can add to your game. There are plugins here that you can use and there's a lot of JS scripts out there that you can plug in to make your project really unique.

    But I am going to agree with oosyrag when he says that the visual aspect of your game is it's heart and soul. If you're creating your first game sure, just use whatever works and doesn't cost you anything. But, when you're ready to take on the public, first impressions are lasting impressions. You'll have to decide which public assets you can get away with re-using and which you're going to want to be unique.

  • Thanks Nepeo for the detailed reply. Here's what I'm seeing: Every server-sent connection using PHP (blocking asynchronous) creates a new process on the server and holds it. If you get 1000 people playing, that's 1000 processes just for the outgoing chat, nevermind the Ajax calls for incoming messages.

    Long and short polling, using PHP have the same problem. Each call to the server creates a new process.

    Now I've had a short poll PHP chat up and running on my server and working perfectly inside the HTMLElement plugin. You said you had short poll working on a commercial product but how many polls per second can Apache really deal with? I understand Ngix works a bit better in this department but thats a whole new ball of wax. Either way, it still seems like a lot of processes firing up and shutting down on the server.

    Ashley I'm leaning toward your thinking but... I had to watch a 'noob' video on node.js just to figure out how it worked. Yea, I'm that js ignorant. So, for me, it would be easier to create a C# ws server using a library I found called Fleck and try to compile it under monodevelop for Linux. Problem there, that's going to require a virtual server somewhere that I'm going to have to manage. I tried to install a basic node.js web server (the example one) on my current host and got slapped. My host politely informed me that I'd need a virtual server for that too.

    Right now, the only thing I've found that may be a viable solution that's not going to require me managing a server (I haven't played with it yet) is a PHP library called React.

    Of course, money solves many of those issues I suppose.

  • Ok, I've just had an epiphany. I've been contemplating a chat system for my latest project. The options I had up until a few moments ago were:

    Long polling - whereby the game client sends an AJAX request every second or so to see if there are any new chats it needs to grab. While this system definitely works, I can see it turning a web server into a puddle of goo when you have 1000 clients polling for chats every second along with trying to serve up web pages and responding to other AJAX requests.

    Websockets - whereby I write some websocket server in node.js or c# and have it run as an application on a server somewhere with the game client logged into it. While this would be duplex, instantaneous and efficient, trying to configure a wss server and write the code for it sounds like a nightmare. Not to mention the fact that it would pretty much required a dedicated server somewhere so that it could run continuously.

    And then my epiphany:

    Server-Sent events - I just read about these here:

    https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events

    and decided to test it out and ummmm... wow.

    So, I dropped an HTMLElement plugin on my layout and put this in the text field:

    <ul><div id="screen"></div></ul>
    

    I then took my js file with all my bits of code and added this (with the url pointed to the php on my web server)

    var evtSource = new EventSource("//api.example.com/ssedemo.php", { withCredentials: true } ); 
    
    evtSource.onmessage = function(e) {
     var newElement = document.createElement("li");
     var eventList = document.getElementById('screen');
    
     newElement.innerHTML = "message: " + e.data;
     eventList.appendChild(newElement);
    }
    
     evtSource.addEventListener("ping", function(e) {
     var newElement = document.createElement("li");
     var eventList = document.getElementById('screen');
     
     var obj = JSON.parse(e.data);
     newElement.innerHTML = "ping at " + obj.time;
     eventList.appendChild(newElement);
    }, false);
    

    I took the php code from the URL above, added in a CORS header, which is really nice because I can pretty much guarantee that it'll be coming from the game, and ran my project.

    To my amazement, I started receiving messages from the php script.

    message: This is a message at time 2019-05-29T13:46:09-0400

    ping at 2019-05-29T13:46:10-0400

    ping at 2019-05-29T13:46:11-0400

    ping at 2019-05-29T13:46:12-0400

    ping at 2019-05-29T13:46:13-0400

    ping at 2019-05-29T13:46:14-0400

    ping at 2019-05-29T13:46:15-0400

    ping at 2019-05-29T13:46:16-0400

    message: This is a message at time 2019-05-29T13:46:16-0400

    ping at 2019-05-29T13:46:17-0400

    ping at 2019-05-29T13:46:18-0400

    ping at 2019-05-29T13:46:19-0400

    ping at 2019-05-29T13:46:20-0400

    Now normally, web hosts force php scrips to crash and burn after a set time. This one, 30 minutes later, is still sending pings to my C3 game client. So, either my host has lost their mind or,

    The only downside 2 downsides I can find to this so far is that:

    • It doesn't work in Edge and IE browsers (which I can certainly live with since IE is dead and Edge is switching to Chromium).
    • It's not duplex, it's a one way communication from the server to the client. BUT - Ajax requests to send in chats from the client and server-sent events to feed out the chats should work.
    • When running the php script above on Apache it opens a new process for every single client that connects. You get 1000 clients and you turned your server into goo again. A huge drawback.

    Now, according to this post:

    https://stackoverflow.com/questions/14225501/server-sent-events-costs-at-server-side

    Node.js should be able to handle server-sent events with just one process and have thousands of clients connected.

    Anyone else played with server-sent events? Any thoughts?

  • I guess it depends on how you want to term it.

    Games like Rust use Unity as the engine behind their game.

    Games like Eve Online, which is created primarily in Python, the game is the engine.

    To coders, it's semantics...

    To the public though, it's public perceptions and thus, marketing. When the word engine appears, people think of that thing under the hood of their car that makes it go. To most, it's a mysterious, mechanical marvel that they can stare at in wonder and admire, but don't have to think too much about. Calling the code behind a game an 'engine' imparts that same mystery.

    It's the same exact reason that the food industry wants to change 'high-fructose corn syrup' into 'corn sugar': public perceptions and thus, marketing.

  • Not really. You could try to encrypt the local variable and that would deter most people. The problem there is, any password you use to encrypt and decrypt it would be located somewhere in the code. Anyone dedicated enough would eventually find a way to decrypt it. (Trust me, I've had keygens made for software I've written).

    I'm doing something very similar to what you are. I have skills that require x amount of time before they can be trained. What I do is send an AJAX request to a PHP file when they choose a skill to train. When it gets that request it stores that timestamp in a MySQL database. When the user logs in, it sends an AJAX request to retrieve that timestamp. It compares it to the current timestamp and if enough time has elapsed, it sends another AJAX request to update their skills. If the time hasn't elapsed, I have a 1 sec timer on a global event sheet that keeps checking to see if that time has elapsed.

    But, you even have to take other things into account. What if they change the clock on their computer to be say, a week in the future? You'd need some way to validate the current time.

    If people want to hack your game, they will. All you can do is make it as difficult as possible. My solution isn't perfect but, storing things like that remotely on a server is about the best you can hope for.

  • So this is just a thought running around in my head, bear with me.

    Along with Construct, I code professionally in PHP (yep, people actually pay me to write code, amazing). Of late many of the questions I've been answering on the forums either have a direct relation to AJAX and JSON or could be solved with AJAX and JSON. Right now, the solution for Construct programmers is to write their own code to handle these problems or learn the rigors of Firebase. The problem is, most people who write code for Construct have little or no knowledge of other languages.

    So this got me to thinking.

    If there were a service available that would allow you to do the following, would it be of interest?

    Using AJAX, create user accounts and store information like:

    • User name
    • Password
    • Email
    • Date Created
    • Number of logins
    • Last login
    • IP Address

    Email validation.

    • Send the user an e-mail when they create an account with a link that they can click on (or an in-game form) to verify their e-mail.

    Validate user logins:

    • Using AJAX, send a username and password and have it return whether the account is valid or not.

    Store and retrieve various variables:

    • The ability to send AJAX requests that store variables and retrieve them on demand, like high score, timestamps, current level, etc.

    Essentially, it would work like this:

    You send an AJAX request to a server. For example, to check if a user can login you'd send:

    AJAX url : http://www.constructusermanager.com?name=username&password=password&apikey=somehashedkey

    and it sends you an JSON in return.

    {

    "valid": true

    }

    Take note, this would be a HUGE undertaking on my part. While I envision allowing a free account where you could test say 5 users maximum, anything beyond that would require a monthly fee.

    And this is just me thinking out loud. Nothing written in stone...

    What are your thoughts?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Browser.ExecJS("Date.now()") will give you the number of milliseconds between 1/1/1970 and now. You can put that number into local storage whenever you wish. When the user starts the game the next time, you can get that number again and subtract the stored value from the current value and know exactly how many milliseconds has elapsed since you stored that number.

    Browser.ExecJS("Date.now()") - stored value = milliseconds elapsed.

    One thing to take note of. Storing variables in local storage is not secure in any way. It's entirely possible, and not that difficult, for a user to go in and edit those variables manually.

  • Then he's not missing anything. What he wants is exactly what I described in the Delphi panels. If you drop a button on a panel in Delphi and you anchor the button to the bottom right of that panel, regardless of how that panel changes in size, the button will always maintain the same x and y position relative to the bottom right of the panel. Once the alignment of the panel and the anchoring of the components is set, you never have to screw with it again.

    There is nothing in Construct whereby I can layout objects and have them maintain their relative position to... well anything. Even pin has it's issues. I can't pin a button to the layout and have it stay in that spot. Instead, I'm forced to create a function that I have to call every time a layout starts or the browser resizes and I have to go through every single visible object on the layout and tell it exactly where I want it positioned and if I want it resized, relative to the viewport dimensions.

    For example. In the project I'm working on I have a sprite in the top right corner of the layout. I ALWAYS want it 10px from the top and 10px from the right, regardless of how the browser is sized. With a Delphi panel, I set it's anchors to top and right and place it... done. In Construct I have to tell it... no, no, I want you HERE... now DON'T MOVE.

Fengist's avatar

Fengist

Member since 6 Nov, 2015

Twitter
Fengist has 5 followers

Trophy Case

  • 9-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • x3
    Coach One of your tutorials has over 1,000 readers
  • x2
    Educator One of your tutorials has over 10,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

16/44
How to earn trophies