Game Sample: Speak Method

This method is a small part of a game I worked on. The purpose of the method is to create a life-like output of words, to mimic dialogue and feel more realistic when characters are communicating.

The method takes a string which is the words to be output, an int which represents, in milliseconds, the pause between each word, and another string, speaker, which is the name of the person speaking.

This method works in a fascinating way and really is able to break down a barrier which is often present in text based games, the lack of realistic interaction.

I am not sure if I will post the entirety of this adventure on my site, but I will continue to update on methods which go into the game.

Screen Shot 2018-01-28 at 11.39.59 AM

    Method which creates life like speech by dividing up and outputting single words seperated by intervals

void speak(string statement, int pause, string speaker){
    cout << endl;
    //temp string and stringstream are created
    string temp;
    stringstream ss(statement);
    cout << speaker << ":   ";          //Creates pauses between the output of words     while(ss >> temp){
        cout << temp << " " << flush;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s