Re: Using handles in bgt somewhat confuse me

They're a little weird, but if you just play around with them you'll figure it out. The main use I've gotten out of them is when creating object arrays. Seriously, they're useful.
Here's an example, maybe it'll be helpful, maybe not.
sound@ [] sounds; //Creates an array of sound objects with 0 entries.
void main()
{
show_game_window("Testing handles");
do
{
if(key_pressed(KEY_SPACE))
{
if(sounds.length()<10)//This will prevent there from being more than 10 entries created in the array.
{
sounds.insert_last(sound());//Creates a sound object and places it at the end of the array.
int entry=sounds.length()-1;//Gives us a variable to reference the last entry so we can load and play it.
sounds[entry].load("c:\\windows\\media\\ding.wav");//Load the file into the sound object located within the sounds array.
sounds[entry].play_looped();//Plays the sound in a loo p
sounds[entry].pan=-100;//Gives all sounds a base pan of -100;
}
}
for(uint x=0; x<sounds.length(); x++)
{
sounds[x].pan=x*20-100;//Sets the pan value of the x entry of the array to mirror its location in the array.
sounds[x].pitch=0+10*x;//Changes the pitch to reflect the entry's location within the array;
}
}
while(!key_pressed(KEY_ESCAPE));
}

If you paste this example into a notepad and rename it to a .bgt file and run it, you'll notice that the sounds pan from left to right as you press the spacebar, and also increase in pitch as they go from left to right. This was all done by using an array with 0 entries. I didn't have to create a single object in the script itself. I just create a template in which the script could create its own objects. Like I said extremely useful.
HTH.
Edit, cleaned up the formula that set the pan and pitch locations.

_______________________________________________
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Omar Alvarado via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Victorious via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : sneak via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : sneak via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Omar Alvarado via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : severestormsteve1 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Lucas1853 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : sneak via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Kyleman123 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : sneak via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Omar Alvarado via Audiogames-reflector

Reply via email to