How do I create consecutive days?

0 favourites
  • 9 posts
From the Asset Store
Action packed 2 track pack for use in your projects
  • I tried to search it but i couldn't find a "badge" of playing for x consecutive days.

    I dont want the work / project done, i want to know how you guys could do it.

    Thanks and regards .

  • This may be of use for you.

    https://www.scirra.com/tutorials/940/ho ... -a-project

    You can use it to get the current date and save it in your preferred data structure, which you can then use to compare to previous sessions' data saved with localstorage.

  • So the problem for this is to separate all the date and keep like the month and day, the real problem is when the consecutive days are between last days of the month and first of the next one.

    Its pretty hard xD

    Edited: for the first part (separate) i could use:

    left(text, count)

    Return the first count characters of text.

    right(text, count)

    Return the last count characters of text.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I tried to search it but i couldn't find a "badge" of playing for x consecutive days.

    I dont want the work / project done, i want to know how you guys could do it.

    Thanks and regards .

    could you explain a little bit more? I will try to help you...

    what do you mean with "couldn't find a "badge" of playing for x consecutive days"?

  • i just want to give a badge or a gift when the player plays for example for about 5 consecutive days.

  • i just want to give a badge or a gift when the player plays for example for about 5 consecutive days.

    1 - consecutive day without quit the game (computer)?

    2 - play 120 hours?

    3- play for five day in different days?

    ok, you could try like this:

    1- add an event that every second add 1 to a variable, when a variable is more than 432000 do the event you want, if the player quit the game, the variable will lost the score.

    2- add an event that every minute add 1 to a variable (and save every minut), when a variable is more than 7200 do the event you want.

    3- make the data like 4/3/16 like this= 4316

    if a player play the 4316, add 1 to a variable (because the first time he play the variable would be 0). if the player play another time to the same day, don't add nothing... because the time would be the same 4316.

    if a player play another day, like 4/10/16, will be 41016, so is > than 4316, in this case you add 1 to your variable... and when the player score 5, just do the event you want.

    let me know if is good like this

  • I'm pretty sure the method Javascript used for time is seconds from a certain date (in the past). So it would be easy to compare the current time to the last time they played if you are interested in that method.

  • I mean play atleast once in a day for atleast 5 consecutive days.

    I.e: jun 29, jun 30, jul 1, jul 2 and jul 3. (this should the worst scenario because have some days of the last month and some days of the new one)

    so if i have a variable called consecutivedays.

    the game should do something like this.

    compare last day variable with today variable.

    If: today (month and day) = saved (month and day) do nothing.

    if saved day diferent than today and today is 1:

    if month is Jul and saved is jun: add 1 to consecutivedays variable (need to do it for the whole 12 months u_U)

    else consecutivedays = 1 (reset)

    if saved month = today month and today is 1 greater than saved day: add 1 to consecutivedays variable.

  • Well the data is there, the processing is a bit troublesome due to our calendar system being crap.

    First parse out the relevant information and save to a data structure (array or variable). You'll want to grab the month, year, and day. I don't think you'll need the time. My goal is to convert everything strictly to number of days.

    For each month, you want to convert it to however many days there were BEFORE that month in a year. Lets call these monthDays:

    Jan=0, Feb=31, Mar=59, Apr=90, May=121, June=151, ect...

    So to get the date in days, you would do year*365+monthDays+day. You then compare this final number to the previous one.

    How to deal with leap years and February 29 eludes my limited brainpower at the moment. I imagine it would have to do with using modulo (%) or another set of conditional logic, but yeah... the calendar system is bonkers. Hopefully you get the idea.

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