Re: questions about bgt

Hi,
You'd have to submit the code surrounding that statement for us to help you there. sound_pool.play_stationary has the declarative form of:
int play_stationary(string filename, bool looping, bool persistent=false)
(see remark 1 below for information.)
You might want to try sound_pool.play_stationary_extended (), which has the declarative form of:
int play_stationary_extended(string filename, bool looping, double offset, float start_pan, float start_volume, float start_pitch, bool persistent=false)
(See remark 2 below for information.)
Here is the parameter listing for play_stationary();
filename
The filename to play.
looping
A boolean specifying whether the sound should loop or not.
persistent
An optional boolean specifying whether the sound should be persistent or not, meaning whether or not it should be automatically cleaned up after playback has finished. If this argument is not given, false is the default which means that the sound does get cleaned up.
And here is the one for play_stationary_extended:
filename
The filename to play.
looping
A boolean specifying whether the sound should loop or not.
offset
The point in the sound file where playback should begin, in milliseconds.
start_pan
The starting pan of the sound.
start_volume
The starting volume of the sound.
start_pitch
The starting pitch of the sound.
persistent
An optional boolean specifying whether the sound should be persistent or not, meaning whether or not it should be automatically cleaned up after playback has finished. If this argument is not given, false is the default which means that the sound does get cleaned up.
Remarks:

  1. This method is useful for playing sounds such as the listener's footsteps, game ambiences, etc. A sound that is created with the persistent flag will not be cleaned up after it has finished playing, which otherwise is the default behavior. Instead, an explicit call must be made to destroy the sound. This is useful for non-looping sounds that you wish to be able to reliably manipulate with any of the functions that use slots to identify a particular sound. When set as persistent, a sound slot is guaranteed to stay valid regardless of playback status. This also means that you must be sure to destroy it when it is no longer in use, as that slot will otherwise be locked and not available for reuse by new sounds.

  2. Reuse of remark 1.

Examples for play_stationary:

#include "sound_pool.bgt"

sound_pool sound_environment;
timer walk_timer;

int player_position;
int step;

const string sound_extension=".wav";

const int left=-1;
const int right=1;

const int boundary=200;

void main()
{
show_game_window("sound_pool test");
sound_environment.max_distance=70;
for(int counter=1; counter<15; counter++)
{
sound_environment.play_1d("sounds/sound"+counter+sound_extension, 0, random(0, boundary), true);
}
while(true)
{
check_input();
wait(5);
}
}

void check_input()
{
if((key_down(KEY_LMENU))&&(key_pressed(KEY_F4)))
{
exit();
}
if(key_down(KEY_LEFT))
{
walk(left);
}
if(key_down(KEY_RIGHT))
{
walk(right);
}
}

void walk(int direction)
{
if((direction<=left)&&(player_position<=0))
{
return;
}
if((direction>=right)&&(player_position>=boundary))
{
return;
}
if(walk_timer.elapsed<350)
{
return;
}
step++;
if(step>6)
{
step=1;
}
walk_timer.restart();
player_position+=direction;
sound_environment.play_stationary("sounds/steps/"+step+sound_extension, false);
sound_environment.update_listener_1d(player_position);
}

And here is one for play_stationary_extended:

#include "sound_pool.bgt"

sound_pool sound_environment;
timer walk_timer;

int player_position;
int step;

const string sound_extension=".wav";

const int left=-1;
const int right=1;

const int boundary=200;

void main()
{
show_game_window("sound_pool test");
sound_environment.max_distance=70;
sound_environment.play_stationary_extended("sounds/ambience"+sound_extension, true, 500, 0, -1, 90, false);
for(int counter=1; counter<15; counter++)
{
sound_environment.play_1d("sounds/sound"+counter+sound_extension, 0, random(0, boundary), true);
}
while(true)
{
check_input();
wait(5);
}
}

void check_input()
{
if((key_down(KEY_LMENU))&&(key_pressed(KEY_F4)))
{
exit();
}
if(key_down(KEY_LEFT))
{
walk(left);
}
if(key_down(KEY_RIGHT))
{
walk(right);
}
}

void walk(int direction)
{
if((direction<=left)&&(player_position<=0))
{
return;
}
if((direction>=right)&&(player_position>=boundary))
{
return;
}
if(walk_timer.elapsed<350)
{
return;
}
step++;
if(step>6)
{
step=1;
}
walk_timer.restart();
player_position+=direction;
sound_environment.play_stationary("sounds/steps/"+step+sound_extension, false);
sound_environment.update_listener_1d(player_position);
}
_______________________________________________
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : kingzombie via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : roelvdwal via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Jason SW via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Jason SW via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : kianoosh via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Jason SW via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : kingzombie via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector

Reply via email to