Re: can I get some help with bgt?
I get the impression that most speaker tests just play a single file, already made in stereo.But I never feel like making one of those is worth it.The questions you need to answer first, though:- Do you know how to play sounds?- Do you know the properties of the sound object?- Do you understand how code is executed well enough to combine these?For the first two, the sound section of the manual (reference -> foundation layer -> object reference -> sound) has everything you need.The last one, I think, is where most beginners get stuck.Here's an example solution:(I recommend trying to figure it out for at least another minute, first, though.)void speaker_test() {
sound test;
// Load the narrator saying "left". You can replace this with tts, if you prefer.
test.load("left.wav");
test.play_wait();
// Using an arbitrary sound:
test.stream("test.wav");
test.pan=-100;
test.play_wait();
// Say "right". Again, you can replace the following two lines with tts if you prefer.
test.stream("right.wav");
test.pan=0;
test.play_wait();
test.stream("test.wav");
test.pan=100;
test.play_wait();
}(You could also just use the "left" and "right" recordings, but I generally don't have those.)As for difficulty settings, that is a good deal more complicated. It depends on the style of game, as well as all the underlying details of how it works. If it's a game with enemies, would difficulty make them stronger? Faster? Smarter? More numerous? Harder to predict? If it isn't, then what would you expect would make the game harder/easier?If all you want to do is let the player select a difficulty, then remember it, something like this might work. It isn't my favorite solution, but it's probably the simplest if you don't want to make your own menus from scratch:#include "dynamic_menu.bgt"
// There are two ways you could set up constants for this. This is probably the easiest, but it'd make me kinda nervous using it for something like this:
enum difficulties {
easy, normal, hard, hardest
};
// Create a variable to keep track of the difficulty. We're using an int, since it's often useful to put the difficulty into some calculations at some point.
int difficulty=normal;
// This function returns true if the player successfully picked a difficulty, false if they hit escape or if an error occurred.
bool select_difficulty() {
dynamic_menu difmenu;
// I'll use tts for these. Using recordings instead is a matter of removing the _tts from each one, and replacing the text between quotes with the appropriate filename.
difmenu.add_item_tts("easy", "" + easy);
difmenu.add_item_tts("normal", "" + normal);
difmenu.add_item_tts("hard", "" + hard);
difmenu.add_item_tts("hardest", "" + hardest);
int result=difmenu.run("Choose difficulty", true);
// If you used recordings instead, you'd do something like int result=difmenu.run("select_difficulty.wav", false);
// There is a shortcut, here, if you know that the values are in ascending order. The rest of this example will be the long way, but if you want, you could just do this:
// if(result<=0) return false;
// difficulty=result-1; // Assuming the difficulty constants start at 0, otherwise just say difficulty=result.
// return true;
// The longer way:
if(difmenu.get_item_name(result)=="") return false;
int new_difficulty=string_to_number(difmenu.get_item_name(result));
// Check for valid results. You can skip this part if you care more about having a number than that it is necessarily one of our constants.
if(new_difficulty!= easy and new_difficulty!=normal and new_difficulty!=hard and new_difficulty!=hardest) return false;
// At this point, everything worked, so we set the global variable to the selection, and the program will remember it until we change it again.
difficulty=new_difficulty;
return true;
}That's actually a lot more complicated than I normally do it, but I normally use my own menu class, or at worst just code overly specific menus from scratch.(Also, I typed these into the quick reply box, and haven't run it through the compiler. Misplaced parentheses and quotes are the bane of many a programmer. Well, blind ones without IDEs, anyway; I don't know if that's true for everyone else.)
URL: http://forum.audiogames.net/viewtopic.php?pid=257056#p257056
___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector