satyrsfaction Posted April 10, 2020 Share Posted April 10, 2020 I'm working on a game, and i want the player to be able to switch characters using the select switch. it changes the characters at lightning speed instead of one at a time. I tried using the reset restrainer, i don't know if I'm doing something wrong or if thats not what I should be using. any suggestions? Quote Link to comment Share on other sites More sharing options...
TwentySixHundred Posted April 10, 2020 Share Posted April 10, 2020 The basic concept is either using bit operators as an on/off switch or you can use labels. You can use labels if you're not wanting to use bits, for instance: mainloop blah blahblah if switchselect then goto _restrainer goto mainloop _restrainer if !switchselect then goto _blahblahblah goto _restrainer That's the basic concept, it jumps to the restrainer routine then jumps to whatever routine you're wanting when the switch is released. Quote Link to comment Share on other sites More sharing options...
satyrsfaction Posted April 11, 2020 Author Share Posted April 11, 2020 2 hours ago, TwentySixHundred said: The basic concept is either using bit operators as an on/off switch or you can use labels. You can use labels if you're not wanting to use bits, for instance: if switchselect then goto _restrainer goto mainloop _restrainer if !switchselect then goto _blahblahblah goto _restrainer That's the basic concept, it jumps to the restrainer routine then jumps to whatever routine you're wanting on when the switch is released. OK, this is what I did -- and its still switching heroes too fast... what am I doing wrong? if switchselect then goto _restrainer goto sprites _restrainer if !switchreset then gosub _switchhero : goto sprites goto _restrainer _switchhero t = t + 1 : if t > var7 then t = 1 : gosub _sound2 bank5 return Quote Link to comment Share on other sites More sharing options...
TwentySixHundred Posted April 11, 2020 Share Posted April 11, 2020 33 minutes ago, satyrsfaction said: OK, this is what I did -- and its still switching heroes too fast... what am I doing wrong? if switchselect then goto _restrainer goto sprites _restrainer if !switchreset then gosub _switchhero : goto sprites goto _restrainer _switchhero t = t + 1 : if t > var7 then t = 1 : gosub _sound2 bank5 return Ok so if your condition is in the maingameloop you will want to skip the routine unless the condition is met. So as an example something like this: if switchselect then goto _restrainer else goto _skpblah goto sprites _restrainer if !switchreset then gosub _switchhero : goto sprites goto _restrainer _skpblah _switchhero t = t + 1 : if t > var7 then t = 1 : gosub _sound2 bank5 return I dont know exactly how your program is written so im taking a guess of whats going on 1 Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted April 11, 2020 Share Posted April 11, 2020 Have you looked at the example program on the bB page? randomterrain.com/atari-2600-memories-batari-basic-commands.html#switchselect Quote Link to comment Share on other sites More sharing options...
bogax Posted April 12, 2020 Share Posted April 12, 2020 presumably you want to switch characters the first time you see the switch is pressed and ignore it if it's still pressed ie you need to remember the switch state from last time and then change characters only if it wasn't pressed last time and is pressed this time. something like this if switchselect && enable then gosub change_character if switchselect then enable = 0 else enable = 1 1 1 Quote Link to comment Share on other sites More sharing options...
satyrsfaction Posted April 12, 2020 Author Share Posted April 12, 2020 4 hours ago, bogax said: presumably you want to switch characters the first time you see the switch is pressed and ignore it if it's still pressed ie you need to remember the switch state from last time and then change characters only if it wasn't pressed last time and is pressed this time. something like this if switchselect && enable then gosub change_character if switchselect then enable = 0 else enable = 1 that worked perfectly! thanks. Quote Link to comment Share on other sites More sharing options...
haroldoop Posted April 12, 2020 Share Posted April 12, 2020 I you want to search for it, the technical term for this kind of input treatment is 'debouncing'. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted April 12, 2020 Share Posted April 12, 2020 8 minutes ago, haroldoop said: I you want to search for it, the technical term for this kind of input treatment is 'debouncing'. We switched to "Repetition Restrainer" in 2013. More info: atariage.com/forums/topic/213190-demo-batman/?do=findComment&comment=2769989 randomterrain.com/atari-2600-memories-batari-basic-commands.html#repetition_restrainer_for_fire_button 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.