Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: chapter11studios on Sat 19/04/2003 15:27:16

Title: Are time-triggered music and sound effects possible?
Post by: chapter11studios on Sat 19/04/2003 15:27:16
I'd like to have time-triggered music and sound effects events in my game, but in looking over the documentation I can't seem to get confirmation that it's possible.

Example: I have a scene where the hero is walking along a rocky path with vultures perched in nests overhead. I'd like to do a time-triggered thing where every 15-20 seconds or so, a vulture lets out a screech.

Is this possible in AGS? It seems like it ought to be, but I wanted to make sure before I started planning on different sound effect schemes.

Thanks!
Josh
Title: Re:Are time-triggered music and sound effects possible?
Post by: scotch on Sat 19/04/2003 15:48:01
yeah, all that would be pretty basic.. ags can cover almost anything you would have in an adventure game by now I think.

as an example to play a sound every 80 game cycles you would do this:

In your room script,
In the 'Player Enters Screen' interaction:

SetTimer (1, 80);

Then in the 'Repeatedly Exectute' interaction:

if (IsTimerExpired (1)){
 PlaySound(1);
 SetTimer(1,80);}

That's all there would be to it.
Title: Re:Are time-triggered music and sound effects possible?
Post by: AJA on Sat 19/04/2003 15:48:26
15 seconds = 15*40 (default) game cycles = 600 game cycles.

this goes to the room scripts top:
int timer = 0;

And this to the repeatedly execute function of that room:

while (timer <= 600){  // While the timer is less or equal to 600
    timer++;                  // Adds 1 to the timer
}
if (timer >= 600){         // If the timer is more or equal to 600
    PlaySound(X);         // Plays sound X
    timer = 0;                // Resets the timer
}


This should work...


-EDIT-

*Sigh*
Maybe I should start using those timer functions... they seem so much easier... Tho' I haven't needed timers yet in my projects... :P
Title: Re:Are time-triggered music and sound effects possible?
Post by: Ishmael on Sat 19/04/2003 17:51:34
A reveal: Sledge Hammer and the BlueMoon uses timer in the intro to count when its the right time to get the hole in the glass...
Title: Re:Are time-triggered music and sound effects possible?
Post by: Barcik on Sat 19/04/2003 17:59:45
You can also set up a timer using a counting variable and repeatedly_execute (much the same like usign a proper timer).