Hello there,
I am playing the music from a function called intro.
This function is run in the update loop.
When the game state is intro then intro is showed and this is the moment I'd like to hear some music.
Problem is that the intro function is called every time the update loop restarts and therefore the music restarts everytime producing a choppy noise.
How can I solve this issue?
My code is available here:
https://github.com/ltpitt/pico-8-pong/blob/master/pico-8-pong.p8
Thanks for your time and help :)
something like that?
function togglemusic(n) if (music_playing) then music(-1) music_playing=false else music(n) music_playing=true end end |
also I think there are peeks and pokes for the music whereabouts but I never looked into that.
edit: oups, sorry, not what you asked for.
this should do:
function startmusic(n) if (not music_playing) then music(n) music_playing=true end end function stopmusic() music(-1) music_playing=false end |
call startmusic() in intro()
Sadly it is not working :(
If I use the 2nd function you pasted and then I call startmuc in intro the game starts playing even if I'm still in intro (and I get no music).
there must be something else going on, these function shouldn't interfere with your game logic at all.
You're 100% right, I was using the wrong music code and it started playing - rightfully - my game's sfx :)
Really thanks :)
Did the bot hunt down the words "music"? Cause if so that's pretty malicious
[Please log in to post a comment]