[Paid]Someone to integrate time based progression

0 favourites
  • 10 posts
From the Asset Store
Advanced inventory mechanics for your RPG game (Array-based). Take Items, split them, pick up them, read the description
  • I have a simple game I'm making for a client. The game needs to run while the app is not open or at least appear too. It is an android app. There is a plant growing that has to grow while the app is not running. I'm thinking of checking the time online using the web-socket, browser, or AJAX object. Then use that time to calculate how much time has elapsed since the last time and affect object accordingly. I need someone to show me how to do this and host whatever the method for checking time is used. I've got $20 for anyone who can do this.

    Looks like we've got it working now with web-sockets.

  • -- use this to get the system time

    set variable = Browser.ExecJS("var d = new Date(); d.getTime();")

    -- use this to set a target time

    set finish_time = Browser.ExecJS("var d = new Date(); d.getTime();") + ( time_in_milliseconds )

    -- use this to get the time difference

    set var difference = finish_time - Browser.ExecJS("var d = new Date(); d.getTime();")

    -- compare time. you can also check if difference is -/+ value

    If (browser_time > finish_time) then tree is finished growing.

    This will let you use the local clock rather than calling than making an internet connection

  • Well I didn't know this! Very cool!

  • Oh I forgot if you need to know a percentage of growth.

    then also add the

    var start_time = Browser.ExecJS("time stuff")

    and do an easy

    unlearp(start_time, target_time, browser.execjs("gettime") )

    this will give a 0.0 to 1.0 value to use as a percetange. unlerp() * 100.

    you can then use the % to compare the period of growth of your tree.

  • jayderyu

    After I posted this we got our web-socket server working with date. I couldn't use system time as that would be manipulated. I went to lunch and wasn't able to update the thread so I kinda feel bad sorry, want some free games?

  • I wouldn't use system time, as it can be cheated. Server time should be more reliable. Of course if you don't want to use an internet connection, then system time is your best bet.

  • Unless your doing an online multi-player game. I personally wouldn't really have any concern over it. If however you are doing a online multiplayer game. Then I would agree that you should focus an online check.

    mindfaQ point is also valid. As an example I only have an iPod Touch and if I don't have wifi access then your online time is pretty much near useless :( in fact you have to build redundancies to NOT let the tree grow. while it's off line even if the time would have pass accordingly.

    And on a final note. If they want to cheat they will. The best anti-cheat is a game that's not popular.

    I'm good :) but thanks for the offer.

  • Game design-wise you could put in a "feature" that the tree doesn't grow unless its been visited within a 3-6 hour time frame. So maybe people could cheat the system, but it is alot of hassle.

    Everyday do a date+time check, so if date/time ever becomes earlier than what has previously been set you can impose a punishment, like stunting the trees growth for a short while.

    The new android star wars game has a similar feature where the game stops making money for you if you don't visit back every 6 or so hours.

    (The stock in the shops runs out, until you load up game and manually re-stock the shops.)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Game design-wise you could put in a "feature" that the tree doesn't grow unless its been visited within a 3-6 hour time frame. So maybe people could cheat the system, but it is alot of hassle.

    Everyday do a date+time check, so if date/time ever becomes earlier than what has previously been set you can impose a punishment, like stunting the trees growth for a short while.

    The new android star wars game has a similar feature where the game stops making money for you if you don't visit back every 6 or so hours.

    (The stock in the shops runs out, until you load up game and manually re-stock the shops.)

    We have a sun that stops tree growth after 6 hours actually!

    jayderyu

    I didn't want it to be online either, but we have a leaderboard and the client was concerned with cheaters. The date comes in 2013-12-07 03:33:11 format, how would you advise calculating with that?

  • Well you have an online system. Then you really don't have a choice. So yeah stick with the online system.

    Now are you saying you need to out put that format or do you need to interpret the string into usable number?

    Personally either way I would suggest going to where your getting the number and changing the way your getting the time.

    in PHP using

    mixed microtime ([ bool $get_as_float = false ] )

    would return the time in milliseconds as of . which would be more fine precision for games.(http://php.net/manual/en/function.microtime.php). I really wouldn't suggest working with a full calender time stamp, but instead a numerical one where time is measured off of unix epoch.

    If you need to work with the string value. I would suggest using this as as a starting sample.

    time = tokenate(date, 1, " ")

    hour = int(tokenate(time, 0, ":"))

    min = int(tokenate(time, 1, ":"))

    sec = int(tokenate(time, 2, ":"))

    *to note it might be stringtoint() or toInt() or something like that.

    sec += min * 60

    sec += hour * 60 * 60

    ... keep going for day, month and year. except I would get the difference of year as of launch year of the game.

    I really suggest getting time in ms or seconds of the epoch. Doing so will reduce your work, the server programmers work, bugs and headaches.

    <?php $t=time(); echo($t); ?>

    That would be the easier.

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