Re: how to make cutscenes in BGT?

The cool thing about making games is that there are so many ways to make something, like cutscenes, maps, battels etc. The developer just has to choose it's best way. I was making a cutscene by writing a function that receives a String parameter for the text, and then waits for user to press Enter to continue. I also wrote a similar function that will play a sound either before or after the spoken text or a certain amount of time. But implementing arrays is also a good idea, to avoid repetitive function calls.
Anyway, here's my cutscene code that I wrote for my never-finished game.
bool cutscene_is_playing; // must be set to True when starting a cutscene and False when ending it
sound sound_click, sound_finished, sound_effect; // sound handles for cutscene events

// A function to play an Intro scene,
// that will fade out when user presses Enter.
// I'm using my custom music class here.
void intro_play(string file)
{
music.stream(file);
music.play();
while(music.playing==true)
{
if(key_pressed(KEY_RETURN))
{
music_fade(@music, music.volume, -50, 1000, false);
music.stop();
}
}
}

/*
Plays the current line of a cutscene with a sound file.
The wait parameter, if set to true, will wait the sound to finish, rather than playing it over spoken cutscene text.
P.s., the say function is my custom function for speaking text via sapi or a screen reader.
*/
void cutscene_line(string text, string file="", bool wait_sound=false)
{
if(cutscene_is_playing==false)
{
cutscene_play_finished();
return;
}
sound_effect.load("sounds/cutscene/"+file);
if(wait_sound==true)
{
sound_effect.play_wait();
}
else
{
sound_effect.play();
}
sound_click.load("sounds/cutscene/click.wav");
sound_click.play();
say(text);
while(cutscene_is_playing==true)
{
if(key_pressed(KEY_RETURN))
{
break;
}
if(key_pressed(KEY_ESCAPE))
{
cutscene_is_playing=false;
break;
}
if((key_down(KEY_LMENU))&&(key_pressed(KEY_F4)))
{
exit();
}
}
}

void cutscene_play_finished()
{
sound_finished.load("sounds/cutscene/end.wav");
sound_finished.play();
}

_______________________________________________
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : pauliyobo via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : pauliyobo via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Hrvoje via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : audioracer via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Hrvoje via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : pauliyobo via Audiogames-reflector

Reply via email to