diff --git a/index.html b/index.html index 08bc1be..7ff92bb 100644 --- a/index.html +++ b/index.html @@ -16,10 +16,10 @@

Thanks for playing

diff --git a/text_horror/app.js b/text_horror/app.js index 7e3c42c..9c613eb 100644 --- a/text_horror/app.js +++ b/text_horror/app.js @@ -13,6 +13,14 @@ function load() { }) } +function changeDlg(dlgKey) { + dlgPointer = 0; + typeindex = 0; + dlgLines = dlgFile[dlgKey]; + document.getElementById("dlg-text").innerHTML = ""; + typeWriter(); +} + function typeWriter() { if (document.getElementById("dlg-text").innerHTML.length < dlgLines[dlgPointer].length) { document.getElementById("dlg-text").innerHTML += dlgLines[dlgPointer].charAt(typeindex); @@ -27,6 +35,7 @@ function nextDlg() { if (document.getElementById("dlg-text").innerHTML.length == dlgLines[dlgPointer].length) { //check if text is typed out if (dlgPointer < dlgLines.length - 1) { //check if dlgPointer is not at the array end do { + dlgPointer++; if (typeof dlgLines[dlgPointer] === 'number') speed = 50 / dlgLines[dlgPointer]; else if (typeof dlgLines[dlgPointer] === 'object') { @@ -43,7 +52,6 @@ function nextDlg() { if (dlgLines[dlgPointer].split(":")[0] === "_title") document.getElementById("title").innerHTML = dlgLines[dlgPointer].split(':')[1]; } - dlgPointer++; } while (!(typeof dlgLines[dlgPointer] === 'string') || dlgLines[dlgPointer].startsWith("_")) //again if it's not string if (typeof dlgLines[dlgPointer] === 'string') { @@ -58,8 +66,10 @@ function nextDlg() { } } -function changeDlg(dlgKey = "") { - var dlgPointer = 0; - dlgLines = dlgFile[dlgKey]; - typeWriter(); +function answered(answerId) { + console.log(typeof dlgLines[dlgPointer] === 'object'); + dlgFile = dlgLines[dlgPointer]; + document.getElementById("bubble").addEventListener("click", nextDlg); + document.getElementById("answer-box").hidden = true; + changeDlg(document.getElementById(answerId).innerHTML); } \ No newline at end of file diff --git a/text_horror/dialogue.json b/text_horror/dialogue.json index a9244f7..3dd0970 100644 --- a/text_horror/dialogue.json +++ b/text_horror/dialogue.json @@ -9,10 +9,28 @@ "Can you answer?", { "Yes": [ - "CoooooooolllSADVwqavedWSDV" + "Thats pretty cool! Do you have a nice day?", + { + "Yes, i have a nice day": [ + "Cool bye!" + ], + "No": [ + 0.2, + "Oh...", + 1 + ] + } ], "Also Yes": [ - "MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMGGHWhudujwd" + "That was a weird answer... Is anything wrong with you?", + { + "Yes my name is Peter": [ + "OOOOHHHH! That explains everything." + ], + "No I'm Yannik": [ + "Oh okay... Still weird but have a nice day Yannik!" + ] + } ] } ]