function nextImage(){
    console.log("came to next image function");
    counter = 0;
    var index = getImage();
    var soundNew = new sound('./sounds/nextImage.mp3');
    soundNew.play(); 

    //Not sure if this is how we know game over cause end of images(???)
    if(index == -1) playing = false;

    imageVisitied(index);
    console.log(levelData[0].name);
    var image = levelData[index].name;
    placeholder = levelData[index].placeholder;    
    var url = './images/' + image;
    //Grabs name of file as answer:    
    console.log(image.slice(0,image.indexOf(".")));
    answer = image.slice(0,image.indexOf(".")).toUpperCase();
    
    // service = interpret(stateMachine).start();
    // service.send("INPUT_CHANGE", {
    //   name: "answer",
    //   value: image.slice(0,image.indexOf("."))      
    // });

    // service = interpret(stateMachine).onTransition(current => {
    //   state=current
    //   console.log(current);
    // });    
    console.log(url);
    document.getElementById("guess_image").src = url;
    makeLetters(answer.length);
    loaded = true;
    console.log(loaded)
}
//For background sound to stop global variable needs to be turned to false
For background sound to stop global variable needs to be turned to false
For background sound to stop global variable needs to be turned to false
function nextImage(){
    console.log("came to next image function");
    counter = 0;
    var index = getImage();
    var soundNew = new sound('./sounds/nextImage.mp3');
    soundNew.play(); 
    if(index == -1) playing = false;
    imageVisitied(index);
    console.log(levelData[0].name);
    var image = levelData[index].name;
    placeholder = levelData[index].placeholder;    
    var url = './images/' + image;
    console.log(image.slice(0,image.indexOf(".")));
    answer = image.slice(0,image.indexOf(".")).toUpperCase();
    console.log(url);
    document.getElementById("guess_image").src = url;
    makeLetters(answer.length);
    loaded = true;
    console.log(loaded)
}
function nextImage ( ) { console . log ( "came to next image function" ) ; counter = 0 ; var index = getImage ( ) ; var soundNew = new sound ( './sounds/nextImage.mp3' ) ; soundNew . play ( ) ; if ( index == - 1 ) playing = false ; imageVisitied ( index ) ; console . log ( levelData [ 0 ] . name ) ; var image = levelData [ index ] . name ; placeholder = levelData [ index ] . placeholder ; var url = './images/' + image ; console . log ( image . slice ( 0 , image . indexOf ( "." ) ) ) ; answer = image . slice ( 0 , image . indexOf ( "." ) ) . toUpperCase ( ) ; console . log ( url ) ; document . getElementById ( "guess_image" ) . src = url ; makeLetters ( answer . length ) ; loaded = true ; console . log ( loaded ) }
For background sound to stop global variable needs to be turned to false
For background sound to stop global variable needs to be turned to false
//Not sure if this is how we know game over cause end of images(???) //Grabs name of file as answer:     // service = interpret(stateMachine).start(); // service.send("INPUT_CHANGE", { //   name: "answer", //   value: image.slice(0,image.indexOf("."))       // }); // service = interpret(stateMachine).onTransition(current => { //   state=current //   console.log(current); // });    