Skip to content

amandalatkins/radlibz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Radlibz

Summary

Radlibz is an interactive, single-player game of MadLibs! No friends necessary! This application prompts the user for various parts of speech, names, places, and other words. These words are inserted into a corresponding story to create a new and hilarious tale every time! This story is then read aloud to the player in their chosen accent with our text to speech functionionality.

Prerequisites

  • Web Browser (Chrome, Safari, Firefox, etc)
  • JavaScript

Installing

Copy the repository link.

https://github.com/amandalatkins/radlibz.git

Clone the repository to your local development environment

git clone https://github.com/amandalatkins/radlibz.git

Open index.html in your preferred web browser

Built With

Deployed Link

Game Flow Screenshots

Game Flow

Code Snippets

This code snippet shows the function that integrates the player's responses with the story sentences

// Takes the userResponses array and the sentences array (from the MabLibz API return object) and renders the story
function renderStory() {
    // Create an empty string variable to concatenate onto as we run through our arrays
    var storyHtml = "";
    // Displays the title of the story
    $("#storyTitle").text(title);
    // Loop through all the sentences
    for (var i = 0; i < sentences.length; i++) {
        // As long as the sentences have content and aren't set to 0 (the api returns one 0)
        if (sentences[i] !== "" && sentences[i] !== 0) {
            // Replace this chracter combo with line breaks
            var sentence = sentences[i].replace('\n','<br><br>');
            // Replace this character with bullet point
            sentence = sentence.replace('*','&bull;');
            // add sentence to story
            storyHtml += sentence;
        }
        // Make sure there is a user response for this index
        if (userResponses[i]) {
            storyHtml += "<span class='user-word'>"+userResponses[i]+"</span>";
        }
    }
    // append the story to the DOM
    showStory.html(storyHtml);
    speakText(showStory);
}

This code snippet shows how the app receives user inputs to read the completed story aloud

function speakText() {
    // Get text from textbox.
    var text = $('#showStory').text();
    // Get selected voice from dropdown
    var voice = $('#voiceselection').val()
    // Speak it
    responsiveVoice.speak(text, voice)
}

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License.

MadLibz API data is licened under the MIT License.

Merriam-Webster's Collegiate Thesaurus data is licensed according to their terms of service.

ResponsiveVoice-NonCommercial licensed under ResponsiveVoice Text to Speech

Acknowledgments

Thanks to TailorBrands for assisting with the RadLibz logo. Special thanks to our instructor Jerome and TAs Mahisha and Kerwin for their ideas and guidance.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published