2017-10-25 06:05:10

hi all.
i'd like to try to make cutscenes in style manamon, how can i do? thanks

Paul

2017-10-25 12:26:06

The way I do it is to use a string array containing the lines. If the scene calls for something more complicated, like sounds or music changes, I include these as commands at the end of the line they should follow, separated from the spoken text by |, and each command is separated by \n.
Then, I have 2 functions: one for reading the current line (remember that it's good to let players repeat it before continuing), and one for advancing to the next line, which is where the extra commands are parsed. Explaining how the command-parsing works is a bit much for this post as it is.
Then, when a scene is in progress, call the advance function when the player presses enter, and read when the player presses a direction. Or use whichever controls you want (remappable controls are nice), so long as there's a button or more for each action.
Skipping is a simple matter of clearing the array, unless you're using extra commands that you need to have happen even if the player skips the scene. If not, resize(0) is good enough. If so, you'd need to do more interesting parsing on skipping.

看過來!
"If you want utopia but reality gives you Lovecraft, you don't give up, you carve your utopia out of the corpses of dead gods."
MaxAngor wrote:
    George... Don't do that.

2017-10-25 13:51:13

so basically i need a string with the scene and putting in to the array the scene i'd like so when ever i need it i'll call it?

Paul

2017-10-28 13:25:48

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();
}

2017-10-28 20:00:50

I wonder if you could if you wanted too, is instead of having text being spoken, a person can vocally say a line.

Sincerely:
John Follis
Check out my YouTube Channel.

2017-10-28 20:12:35

Of course! You just make a function that receives a sound handle as parameter, plays that sound, and then waits for user to press Enter or whatever to scroll to the next line.

2017-10-29 10:15:07 (edited by pauliyobo 2017-10-29 10:15:30)

thanks a lot for this example, hrvoje! smile

Paul