Android ¿How to do a Time Checker ?

J

José Roberto Aldana

Guest
Hello, I am developing a videogame and I wanted to know if it was possible to create a time system like clash royale chests? , that the box can be opened only after a certain time has elapsed, and that it does not depend fully on the time of the device. I do not know if I explain, thanks in advance , sorry for my bad english.
 
You mean ingame time or real world time?
In game time is pretty easy, you just gotta set up a counter time system.
For example:
time_second += 1; (this can go quite fast, as that is one second per frame, getting real seconds depends on the framerate of the game you set up)
if time_second = 60 {time_minutes += 1}
if time_minutes = 60 (time_hours += 1}
if time_hours = 24 (time_days += 1}

and so on. This is pretty basic, but with a little bit of creativity you can make it quite complex.

Tip: do not forget to implement a pause function from the beginning of the game. If you start doing all kinds of stuff that depends on such time variables, and having no pause option,
it's gonna be a pain in the *** to re-check all the code you've already written to make it all pause when needed.
 
J

José Roberto Aldana

Guest
Top