Hey everyone! Probably my last post for a while. Just needed one thing sorted: how can i make my in game timer start only when the game in initialized? also, how can i make the timer stop once you reach the final level?
So, the time() function is more a convenience than anything else. Pico-8 set an internal number to 0 when the cartridge starts then adds 1 to it every time the _update function is called. Then when you you call the time() function, it returns the result of dividing the internal number by the framerate implied by the version of _update you are currently using.
You can get the needed effect by setting a variable such as game_time to 0 in your init_game function, then adding 1 to it in your update_game function unless the final room has been reached. Then, when you need to display the time in seconds, use game_time/30.
Before the game starts, your timer is 0.
During levels, your timer is time()-start_time
After entering your last screen time, your timer is end_time-start_time.
In your code,
when entering 1st level, start_time=time()
when entering victory screen, end_time=time()
[Please log in to post a comment]