From d192958849c1600734acea828f91c9eac3a0bbfc Mon Sep 17 00:00:00 2001 From: Yannik <80621863+vaporvee@users.noreply.github.com> Date: Fri, 26 May 2023 22:31:32 +0200 Subject: [PATCH] triangle now hides while typewriting --- index.html | 2 +- text_horror/app.js | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index 68f575a..0c78142 100644 --- a/index.html +++ b/index.html @@ -10,7 +10,7 @@ TextHorror - +

Thanks for playing

diff --git a/text_horror/app.js b/text_horror/app.js index c54779f..eec1ef6 100644 --- a/text_horror/app.js +++ b/text_horror/app.js @@ -15,20 +15,27 @@ function load() { } function typeWriter() { - if (document.getElementById("bubble").innerHTML.length - 1 < dlgLines[dlgPointer].toString().length) { + if (document.getElementById("bubble").innerHTML.length < dlgLines[dlgPointer].toString().length) { document.getElementById("bubble").innerHTML += dlgLines[dlgPointer].toString().charAt(typeindex); typeindex++; - setTimeout(typeWriter, speed);//loops because of running "typeWriter" after waiting + document.getElementById("triangle").hidden = document.getElementById("bubble").innerHTML.length != dlgLines[dlgPointer].length + setTimeout(typeWriter, speed); //loops because of running "typeWriter" after waiting } } -function mouseClick() { - if (document.getElementById("bubble").innerHTML.length == dlgLines[dlgPointer].length) { - if (dlgPointer < dlgLines.length - 1) { - dlgPointer++; - while (!(typeof dlgLines[dlgPointer] === 'string')) dlgPointer++;//again if it's not string +function mouseDown() { + document.getElementById("triangle").hidden = true; +} + +function mouseUp() { + if (document.getElementById("bubble").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++; + while (!(typeof dlgLines[dlgPointer] === 'string')) //again if it's not string typeindex = 0; document.getElementById("bubble").innerHTML = ""; + document.getElementById("triangle").hidden = true; typeWriter(); } else { document.getElementById("bubble").hidden = true;