diff --git a/text_horror/app.js b/text_horror/app.js index 786a5a9..ba7932c 100644 --- a/text_horror/app.js +++ b/text_horror/app.js @@ -7,6 +7,7 @@ var skipDlg = false; var answers; var keys; var allowNextDlg = true; +var voice; function load() { fetch("text_horror/dialogue.json") //Load json file here @@ -31,7 +32,6 @@ function changeDlg(dlgKey) { } function updateDlg() { - console.log(dlgLines[dlgPointer]); typeindex = 0; document.getElementById("dlg-text").innerHTML = ""; document.getElementById("triangle").hidden = true; @@ -41,6 +41,10 @@ function updateDlg() { function typeWriter() { if (typeindex < dlgLines[dlgPointer].length) { document.getElementById("dlg-text").innerHTML += dlgLines[dlgPointer].charAt(typeindex); + if (voice != null && typeindex % 3 == 1) { + voice.load(); + voice.play(); + } typeindex++; setTimeout(typeWriter, speed); } else if (allowNextDlg) @@ -65,6 +69,13 @@ function nextDlg(dlgPointerIncrease = true) { document.getElementById("title").innerHTML = dlgLines[dlgPointer].split(':')[1]; nextDlg(); } + if (dlgLines[dlgPointer].split(":")[0] === "_voice") { + if (dlgLines[dlgPointer].split(':')[1].length != 0) + voice = new Audio("text_horror/assets/voices/" + dlgLines[dlgPointer].split(':')[1] + ".wav"); + else + voice = null; + nextDlg(); + } } else updateDlg(); } diff --git a/text_horror/assets/voices/spitzkopf.wav b/text_horror/assets/voices/spitzkopf.wav new file mode 100644 index 0000000..d3c34d3 Binary files /dev/null and b/text_horror/assets/voices/spitzkopf.wav differ diff --git a/text_horror/dialogue.json b/text_horror/dialogue.json index 3e378f6..9c27e14 100644 --- a/text_horror/dialogue.json +++ b/text_horror/dialogue.json @@ -15,6 +15,7 @@ ], "Also Yes": [ "_title:Spitzkopf", + "_voice:spitzkopf", "That was a weird answer... Is anything wrong with you?", { "Yes my name is Peter": [