Real Time Based Lives

Hello all. First of all Merry Christmas and wish you have all best. I have been struggling to find a way to add real time based lives time to my game like candy crush etc. I couldn't make it. Can anyone please help me out with that? I am not very professional on game salad btw. Thank you already.

Wish you health wealth and all the best for Christmas.

Comments

  • adent42adent42 Key Master, Head Chef, Executive Chef, Member, PRO Posts: 3,170
    edited December 2020

    Depends on what you mean. I'm gonna guess you mean: give award after x hours.

    1) Create an integer attribute: awardTimerStart

    2) When the award timer needs to start, set awardTimerStart to the following formula (adjust the variables to match the gamesalad versions of the variables from the device.clock:

      (

       ((year - 1970)*356) + FLOOR(((year-1968)/4)-0.25) - MIN(MAX(year-2100,0),1)

       + MAX(((FLOOR((A3-1)*30.4)-(1-ROUND((A3-1)/14)) * MIN(ABS(2-A3), 1)) * MIN(ABS(2-A3), 1)) + MAX(1-MIN(ABS(2-A3), 1),0)*31,0)

       + (MIN(ROUND(month/5),1) * FLOOR(1-MOD(year,4)/4))

       + days

      ) * 24

    That gives you the number of hours since Jan 1, 1970 and is good until the year 2200 when the 400 year leap year rule comes into affect again. If you assume your game won't last until 2100, you can remove to save a little math: "- MIN(MAX(year-2100,0),1)"

    3) Save the attribute value and load it every time you start the game, if you want "Real time" to work between game sessions.

    4) Use a timer to check the current time against the stored awardTimeStart value using the same formula. Once the appropriate number of days passes, award the user, clear the attribute and save the cleared value.

    Multiply the formula by the appropriate value and add the clock value for each increment of time you want to double check against.

    The only bad thing is, because we're using system clock time, the user could cheat by changing their clock.

    You'd need something that could sync cock time against a server. If you're willing to trust the time with a margin of error, you could use the network behaviors to verify the user time and do the math to correct it.

  • adent42adent42 Key Master, Head Chef, Executive Chef, Member, PRO Posts: 3,170

    Once we can finally work on GameSalad 1.26, I'm just gonna add epoch time to the clock so we can avoid this formula :)

  • cagrisavancagrisavan Member, PRO Posts: 19

    Hi Adent. Sorry for late reply. I was busy during Christmas. Thank you so much for replying. Well, what I mean was player will start game with 5 lives if he/she can't pass the level then he/she will lose -1 lives. When all the lives are finished the player should wait 5mins to get 1 lives, 10mins for the 2nd, 15 mins for 3rd, 20 mins for 4rd and 30 mins for 5th lives. I did not quite understand where to put formula. I am making a really nice sci-fi maze game and it has its own story which will attract the players. I have 2 more big issues and I can't solve them. I watched video how to draw a path have actor follow it https://www.youtube.com/watch?v=jV21QXylByU. First problem, I added collide behavior to actor, when I draw a path actor hits wall stops at edge of wall or inside the wall when i draw a new pat or click on screen actor passes through walls. I want actor to stop where it collides with wall but not inside the wall. Second problem, when actor receives double click no matter if its stopped or moving, it goes to right bottom corner of the screen and comes back. As I told you before, I am not very skilled on Gamesalad, so can you please describe me simple way. Thank you already have nice week

Sign In or Register to comment.