How do I make a game track real time while closed, in the style of a virtual pet/tamagotchi?

Not favoritedFavorited Favorited 0 favourites
  • 6 posts
From the Asset Store
For dark exploration, survival, horror, platforms, adventure, fantasy games.
  • Link to my project file so far: drive.google.com/file/d/1rJ8leDVFRthd8AYcR2uff6x8tf7ljnVh/view

    I'm relatively new to C3, having experimented briefly and sporadically, and I'm now trying the strategy of "Make a thing, and only research/get help with specific steps, rather than following a tutorial" to see if it sticks better!

    I'm trying to make a virtual pet similar to a tamagotchi, where real time passing causes it to continue aging/growing/dying even when closed.

    Currently, I've made an (accelerated) egg stage, where the egg first just needs time to grow and heat to stop it dying, then needs comfort (tapping when it is restless) to build up in combination with being warm to gain energy, and then the egg would hatch when you keep the energy and warmth correct for long enough (but right now it just says you won and pauses the game).

    I've implemented the bog-standard save/load system, and my googling suggested using the 'unixtime' expression to figure out the number of milliseconds since last saved.

    I'm sort of stuck on that because in my test, subtracting the current unixtime on load from the saved unixtime is always outputting a negative number that seems to always be the same, -17xxxxxxxxxxxxx.

    So my question is really, how do I do this right, and if I'm on the right track, what am I missing here?

    Thanks!

  • You are on the right track, but you need to use "On load complete" trigger, because loading doesn't happen instantly.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks! I’ll definitely check that and see if I can move on to using that to trigger stat updates.

  • The answer above solved my initial problem, but I now have a related question!

    New/updated file: drive.google.com/file/d/1rJ8leDVFRthd8AYcR2uff6x8tf7ljnVh/view

    I'm using the default save/load system, and I'm aware from Googling it that you can't just "clear" a save slot.

    Because my game is meant to be like a traditional vpet, it is meant to constantly save and then load automatically when you open it up... which means that I can't use the normal 'restart layout' effectively, because it just loads the save slot on the start of the layout over and over again.

    This has led to me needing to keep changing the save slot ("mysave" becomes "mysave1" becomes "mysave2," etc) to test out how it behaves when starting from scratch when I make relevant changes.

    Now, it hasn't actually stopped me from proceeding, because I have a reset button that kicks things back to start MOST of the time, as long as the changes I've made aren't incompatible. But it's annoying, because sometimes if I'm changing certain things they don't properly reset (ie, I changed the dimensions on a sprite and it appeared stretched into the OLD dimensions until I changed save slots).

    Is there any better way to solve this problem?

  • If you load the game on start of layout, but also want sometimes to restart the layout without loading, here is the easiest solution:

  • Thanks! That makes sense, but I guess I was too in the weeds to think through the simple version. I’ll try it out!

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