Help me lift system

Hi everyone, I need help creating a life system similar to Candy Crush.

I want to make a system where the player has a limited number of lives (for example, 5). Each time the player plays a level and loses, they lose one life. Then, a timer should start (for example, 30 minutes) to automatically restore that life.

The important part is that the timer should keep running even if the app is closed. So, if the player loses a life and closes the game, when they come back after the required time, the life should be restored (or even more lives, depending on how much time passed).

I’d really appreciate if someone can guide me step by step on how to make this work properly. Thanks a lot in advance!

You can’t do things while the app is closed. But, you might be able to use the Time() expression to get real world time values and compare to that. Basically you would want to store relevant information about the time when the life is lost, so that you can later check if the current time is 30 minutes past the saved time. I guess for that you would only need to store the minute (Time(ā€œminā€)), then check if the current minute is either +30, or greater than stored minute - 30 (if it went to a new hour)

You can download my example of a life system on my itch

The first download on the page is the GDevelop project file which you can download, unzip and open in GDevelop.

It is set up to refill one life every 5 minutes up to a maximum of 5 lives. If you would like to make it longer you would change the Global Variable RegenLength and set it to how long you want it to take, in milliseconds. So for 30 minutes you would change RegenLength to 1800000.

You can try it in a browser first, although I must warn you it looks pretty rough on LibreWolf.

Friend, but with this system, the lives will continue to load and will be recovered whether the user has the application closed or not.

You could do something like check the time of the device before the game closes, then save that as a file. When the player opens the game again load that file and check what time it is on the device again and then calculate. For example if you got a heart an hour and it’s 12:30 when they close the game, the player would get 3 hearts at 3:30.

Yes in my example the lives are recovered whether the user has the application closed or not. Isn’t that what you wanted? If you try the browser example which is based on 5 minute refills, and use all your lives and close the browser and come back in half an hour, you will see it is back up to 5 lives.

Yeah, I checked out the extension, it does what you want.

1 Like