Help with a do loop

2014-11-15 Thread AudioGames . net Forum — Developers room : Orin via Audiogames-reflector


  


Help with a do loop

Hi all,So in this other project I have, Ive got a menu with music working as well as having the speech manager class up and running.I also again got unexpected end of file, but I have less code with this so its easier to work with as theres a total of about four braces.The idea is to create a do loop in the menu that checks to see if one of the choices in the menu is selected, where it will then call the functions. Game i dont have coded yet but Ill start as soon as I get this sorted, speech options should call configuration from speech manager, and exit calls exit to exit the game of course. This time Im breaking up all my functions into includes, I just cant deal with five-10 functions, all dealing with different things in one file. Im talking about functions that branch off into different things entirely. This time Ill make an object for player interaction and another for enemies--I also did try to make an 
 effort to indent this time, especially with the do loop since theres lots of braces in it but not as much as I have to keep track of in the Memory Train Deluxe file. How do I turn on mismatching indents in NVDA? People were talking about but I have never scene it. The way I understand these closing braces is that the first right brace closes the if statement for choice four exit, the second one closes the do loop, and the third closes the main function.Thanks for your help all. Code:#include dynamic_menu.bgt
#include speech_manager.bgt
//The main menu, speech and other things.
speech_manager speech;
sound music;
void main()

{

speech.init(Config.dat, 9223315);

music.stream(sounds/music/mainmenu.ogg);
music.volume = -10;

show_game_window(Test);
dynamic_menu menu;
set_error_output(error.log);
music.play_looped();
int result;
menu.set_speech_mode(speech.mode);
menu.set_tts_object(speech.sapi);
menu.add_item_tts(start);
menu.add_item_tts(Speech Options);
menu.add_item_tts(exit);

int choice;

result=menu.run(Please choose an option., true);
do
{if(choice==1)
{
game();

}

else if(choice==2)
{speech.configure();
}
else if(choice==3)
{exit();

}
}
}

URL: http://forum.audiogames.net/viewtopic.php?pid=194920#p194920




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Help with a do loop

2014-11-15 Thread AudioGames . net Forum — Developers room : Orin via Audiogames-reflector


  


Help with a do loop

Hi all,So in this other project I have, Ive got a menu with music working as well as having the speech manager class up and running.I also again got unexpected end of file, but I have less code with this so its easier to work with as theres a total of about four braces.The idea is to create a do loop in the menu that checks to see if one of the choices in the menu is selected, where it will then call the functions. Game i dont have coded yet but Ill start as soon as I get this sorted, speech options should call configuration from speech manager, and exit calls exit to exit the game of course. This time Im breaking up all my functions into includes, I just cant deal with five-10 functions, all dealing with different things in one file. Im talking about functions that branch off into different things entirely. This time Ill make an object for player interaction and another for enemies--I also did try to make an 
 effort to indent this time, especially with the do loop since theres lots of braces in it but not as much as I have to keep track of in the Memory Train Deluxe file. How do I turn on mismatching indents in NVDA? People were talking about but I have never scene it. The way I understand these closing braces is that the first right brace closes the if statement for choice four exit, the second one closes the do loop, and the third closes the main function.Thanks for your help all. Code:#include dynamic_menu.bgt
#include speech_manager.bgt
//The main menu, speech and other things.
speech_manager speech;
sound music;
void main()

{

speech.init(Config.dat, 9223315);

music.stream(sounds/music/mainmenu.ogg);
music.volume = -10;

show_game_window(Test);
dynamic_menu menu;
set_error_output(error.log);
music.play_looped();
int result;
menu.set_speech_mode(speech.mode);
menu.set_tts_object(speech.sapi);
menu.add_item_tts(start);
menu.add_item_tts(Speech Options);
menu.add_item_tts(exit);

int choice;

result=menu.run(Please choose an option., true);
do
{if(choice==1)
{
game();

}

else if(choice==2)
{speech.configure();
}
else if(choice==3)
{exit();

}
}
}edit: So I put this particular file through the BGT matcher, and it says I have 22 quotes which I suppose should be normal for the parameters of functions require them around quotes, but 0 unclosed braces and 0 unclosed brackets. This tells me that its not a braces error but something logical or syntax related? Thats good to know as its only my second do loop.

URL: http://forum.audiogames.net/viewtopic.php?pid=194920#p194920




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Help with a do loop

2014-11-15 Thread AudioGames . net Forum — Developers room : keyIsFull via Audiogames-reflector


  


Re: Help with a do loop

You never actually gave a condition for the loop to keep running. It would go just before the final right brace in your code. The condition looks liekwhile(condition);basically the do loop will continue running while that condition evaluates to true, and the condition is checked after every execution of the loop. This means the loop will run at least 1 time.development hint: This is not a prolem in the code, but you may want to remove the if statement for option 3 and make that your while condition. This would make the program continue execution past the menu loop if option 3 was selected. Since there is, currently, nothing beyond the do while loop except the end of the main function, that should, in effect, quit your game.

URL: http://forum.audiogames.net/viewtopic.php?pid=194941#p194941




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Help with a do loop

2014-11-15 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: Help with a do loop

NVDA will not tell you about mismatches. NVDA will announce changes in indentation. The trick is that you always know what level youre at, not that you suddenly get an auto-matcher out of it. If the level isnt back to 0 at the end of a function, for example, then youve missed a brace. If the level goes to 0 before the end of a function, then youve got an extra. Doing it will eventually become first nature, which is better than second nature until you realize you cant turn it off even though your editor has decided to help you (not likely to be an issue for a BGT programmer). Its in the formatting dialog.Since I toggle it so often, nvda+n, p, f, i, space, enter.As for your code, its the second-to-last brace. The syntax of do is:do {statements...} while(condition);It is worth noting that if that code was indented, it was lost when you brought it to the 
 forum.Since BGT is not a big deal like C++ and Python, I cant give you specific best practices for style. But coming up with style rules is important, and I suggest following them religiously. You may eventually wish to switch to what is known as one true brace, that is:do {
} while(condition);
if(condition) {
}
else {
}
while(condition) {
}But this doesnt matter so much for languages where the community isnt large enough to have a default that spans 20 years, and your current style certainly makes checking to make sure you actually put them in easier. The advantage to one true brace, as far as Im concerned, is that its simply less to arrow through. Im not criticizing, just providing something you might want to be aware of. Its common in C/C++/Java.And finally, theres always the find comments. They dont really have an official name. Basically its leaving comments in that are easy to find for--for example, //todo: or, in the case of Libaudioverse, //begin public API. This is extremely helpful in really big files. You can split things up, but not always. 500 line files are common in the real world. My biggest is, ironically, almost exactly 666 lines. Anything bigger than that may b
 e too much. The worst Ive seen is a 1-line single-file library for playing audio that included code for 3 platforms in the same file and, ironically but not surprisingly, failed to work right. If youre wondering about navigation, it comes down to learning find/replace and, if you can, getting an editor with find by regular _expression_ for those times when nothing else will do. This is one thing that C++ makes ironically easier: if youre blind, the header file makes a great table of contents for the much larger source files.

URL: http://forum.audiogames.net/viewtopic.php?pid=194943#p194943




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Help with a do loop

2014-11-15 Thread AudioGames . net Forum — Developers room : stewie via Audiogames-reflector


  


Re: Help with a do loop

Also.when you run the do loop, you dont actually call the menu for each loop iteration. so if you chose a result say 0, that do loop would execute forever and bog down your system.

URL: http://forum.audiogames.net/viewtopic.php?pid=194944#p194944




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Help with a do loop

2014-11-15 Thread AudioGames . net Forum — Developers room : stewie via Audiogames-reflector


  


Re: Help with a do loop

Also.when you run the do loop, you dont actually call the menu for each loop iteration. so if you chose a result say 0 or -1 after hitting escape, that do loop would execute forever and bog down your system.

URL: http://forum.audiogames.net/viewtopic.php?pid=194944#p194944




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector