+Gemintronic Posted December 20, 2016 Share Posted December 20, 2016 I keep seeing questions about sound. I've tried posting this before but got no feedback. So, this is my attempt with a full working example Basically, at the top of your main game loop you have a variable for a sound effect. If its value is greater than 0 the sound plays. The sound effect value gets decremented and gets its volume turned off at 0. Using the same sound effect variable you can get different noises depending on the duration. So, that saves on using extra variables. rem /** Declare the 2 variables for sound. Putting higher values in changes the duration and sound **/ dim sounda = a dim soundb = b main rem /** if a sound variable is greater than 0 play sound effect and decrease its value. Kill sound if 0 **/ if sounda > 0 then sounda = sounda - 1 : AUDC0 = 8 : AUDV0 = 4 : AUDF0 = sounda else AUDV0 = 0 if soundb > 0 then soundb = soundb - 1 : AUDC1 = 2 : AUDV1 = 4 : AUDF1 = soundb else AUDV1 = 0 rem /** if FIRE or up is pressed start playback of sound effects by putting a value in the sound variables **/ if joy0fire then sounda = 50 if joy0up then soundb = 50 rem /** Start main program loop again **/ goto main simplesound.bas 3 Quote Link to comment Share on other sites More sharing options...
Th0rn Posted December 22, 2016 Share Posted December 22, 2016 Works great, thanks! I was playing around with the Tinkernut program where he shows how to make an Atari game on YouTube and added sound to it. https://www.youtube.com/watch?v=Ww3her2zk_I&t=330s Space Game with sound Hack of Tinkernut.bas Space Game with sound Hack of Tinkernut.bin 1 Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted December 23, 2016 Share Posted December 23, 2016 Works great, thanks! I was playing around with the Tinkernut program where he shows how to make an Atari game on YouTube and added sound to it. https://www.youtube.com/watch?v=Ww3her2zk_I&t=330s The bB page has a Tinkernut version with sound effects: randomterrain.com/atari-2600-memories-batari-basic-commands.html#ex_tinkernut_world_deluxe The bB page also has other sound effect/music examples: randomterrain.com/atari-2600-memories-batari-basic-commands.html#expro_sound Quote Link to comment Share on other sites More sharing options...
Th0rn Posted December 24, 2016 Share Posted December 24, 2016 Thanks for pointing that out. I can play the Tinkernut game in Stella, but I can't load the 53k .bas file in Visual Batari Basic. Visual Batari just says not responding. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted December 24, 2016 Share Posted December 24, 2016 Thanks for pointing that out. I can play the Tinkernut game in Stella, but I can't load the 53k .bas file in Visual Batari Basic. Visual Batari just says not responding. Do you have the latest version of VbB: atariage.com/forums/topic/123849-visual-bb-10-a-new-ide-for-batari-basic/page-28#entry3537039 Quote Link to comment Share on other sites More sharing options...
Th0rn Posted December 24, 2016 Share Posted December 24, 2016 I was using build 554, now thanks to your advice, I am using build 568. I can view it and compile it now. Quote Link to comment Share on other sites More sharing options...
Lillapojkenpåön Posted October 24, 2017 Share Posted October 24, 2017 (edited) Thanks for this and alot of other stuff I've used, I don't know if this can be helpful but I'll leave it here. simplesound2.bas Edited October 25, 2017 by Lillapojkenpåön 1 Quote Link to comment Share on other sites More sharing options...
+Gemintronic Posted October 25, 2017 Author Share Posted October 25, 2017 Yep. There is definitely room for variation. Glad it's been of some use Lillapojkenpåön 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.