Log In  

So I'm fairly new to PICO-8, and while I have a basic (very lightly said, lol) understanding of making a game on the program, I'm having difficulties finding any guides or tutorials about how to use time properly - particularly with making an intro sequence for a game.

Example: After the game starts up, I want to have the music start after 1 second (along with my logo) into the game, but from the methods I've tried, it results in the first note of the track playing in a continuous loop.

if (time()-last)>1 then 

I know the problem is that it repeats the desired action with every value past 1, but I don't know how to only have this happen once.

If there's anyone that knows of any guides/tutorials or has some tips or solutions to this, it would be greatly appreciated.

Thank you!

P#124951 2023-01-28 15:50 ( Edited 2023-01-28 16:16)

You could keep track of frames your self and be wary of it overflowing I find that a lot easier; Like t = 0, t+=1 and then use that and make sure you only test it for things that you should at a given time.
Or if you want to use time() I'm pretty sure it'll always been in a valid state of after each second exactly equalling it's value so you could do if time()==1 then,
or have if time()>1 and flag then flag = false etc
The logic looks a bit odd though is there a reason your state is a while loop instead of uisng a func = state and calling that func in update or whatever?

P#124952 2023-01-28 16:14

To be fair - my coding experience with PICO-8 (and in general) is pretty basic, and I just included the bit I was having the issue with which was under the function _draw() section - whereas the function _update section was saved for the background and scrolling text. I'll mess around with it a bit, but if there's anything else I might be missing, that'd help a lot. Thank you very much!

P#124954 2023-01-28 16:24

Managed to get it working! Thank you again! :D

P#124958 2023-01-28 17:39

[Please log in to post a comment]