Mik's Arcade Posted December 4, 2021 Share Posted December 4, 2021 I was getting a rut when I first starting playing with sound effects, thinking to myself : how am I going to get this game to the finish line!!??! Then, I got the sound of the ninja plummeting to the ground followed by a thud on the ground and brought me right back in. One last question and I think the lesson on sound/music will be complete. I'm now trying to synch up the music to what is going on in the screen. I'm sure you did this a LOT with Christmas Carol. Is there a condition that let's me know music is playing that I can use? For example, I want to stay on the screen (stuck in a loop) I'm on until the music finishes playing, then it break out. So, I want to do something like WHILE MUSIC_PLAYS code DO now I can jump to the next screen GOSUB END Quote Link to comment Share on other sites More sharing options...
+DZ-Jay Posted December 4, 2021 Share Posted December 4, 2021 (edited) 1 hour ago, Mik's Arcade said: I was getting a rut when I first starting playing with sound effects, thinking to myself : how am I going to get this game to the finish line!!??! Then, I got the sound of the ninja plummeting to the ground followed by a thud on the ground and brought me right back in. One last question and I think the lesson on sound/music will be complete. I'm now trying to synch up the music to what is going on in the screen. I'm sure you did this a LOT with Christmas Carol. Well, my core game engine P-Machinery is slightly different from the way IntyBASIC works. While IntyBASIC is more procedural, and runs pretty much in a single linear path, P-Machinery is event-driven, so it affords a kind of multi-tasking. It is also driven by a state machine. In a sense, there is no "main game loop" -- the internal run-time framework takes care of most of that, and triggers system events. So the game is most a bunch of subroutines that get called automatically at the right moment, in reaction to some world event. Sprite movement, animation, music, sound effects, screen scrolling, etc. -- they are all handled automatically, and depending on the situation, may trigger some event. Therefore, if I wanted to let the music play until the end, I would just set a handler for that event and have it change machine states. The game engine takes care of the rest. Quote Is there a condition that let's me know music is playing that I can use? IntyBASIC offers MUSIC.PLAYING, which will return a true (non-zero) value when the music player is engaged, and false (zero) when it is not. Quote For example, I want to stay on the screen (stuck in a loop) I'm on until the music finishes playing, then it break out. So, I want to do something like WHILE MUSIC_PLAYS code DO now I can jump to the next screen GOSUB END You got your loop backwards ... it's either "DO ... WHILE," "DO WHILE ... LOOP," or "WHILE ... WEND": WHILE MUSIC.PLAYING ' Do something ... WEND ' Music stopped playing, we are ready to continue ... GOSUB GameEnd -dZ. Edited December 4, 2021 by DZ-Jay Quote Link to comment Share on other sites More sharing options...
Mik's Arcade Posted December 5, 2021 Share Posted December 5, 2021 5 hours ago, DZ-Jay said: Well, my core game engine P-Machinery is slightly different from the way IntyBASIC works. While IntyBASIC is more procedural, and runs pretty much in a single linear path, P-Machinery is event-driven, so it affords a kind of multi-tasking. It is also driven by a state machine. In a sense, there is no "main game loop" -- the internal run-time framework takes care of most of that, and triggers system events. So the game is most a bunch of subroutines that get called automatically at the right moment, in reaction to some world event. Sprite movement, animation, music, sound effects, screen scrolling, etc. -- they are all handled automatically, and depending on the situation, may trigger some event. Therefore, if I wanted to let the music play until the end, I would just set a handler for that event and have it change machine states. The game engine takes care of the rest. IntyBASIC offers MUSIC.PLAYING, which will return a true (non-zero) value when the music player is engaged, and false (zero) when it is not. You got your loop backwards ... it's either "DO ... WHILE," "DO WHILE ... LOOP," or "WHILE ... WEND": WHILE MUSIC.PLAYING ' Do something ... WEND ' Music stopped playing, we are ready to continue ... GOSUB GameEnd -dZ. Excellent! Thanks again. Tomorrow, I'm going to work out the remaining 3 or 4 music parts I need and plug them into the game to tie it all nicely together. Then I just need to sprinkle in a few more sound effects and polish up loose ends. I need a more smooth transition between events and the WHILE MUSIC.PLAYING WEND loop will take care of it. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.