cleaner code, disabled text and image dragging
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
var speed = 50;
|
||||
var typeindex = 0;
|
||||
var dlgFile = {};
|
||||
let dlgLines;
|
||||
let dlgLines = [];
|
||||
var dlgPointer = 0;
|
||||
|
||||
function load() {
|
||||
@@ -22,22 +22,20 @@ function typeWriter() {
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('click', nextDlg, false)
|
||||
|
||||
function nextDlg() {
|
||||
document.getElementById("triangle").hidden = true;
|
||||
if (document.getElementById("dlg-text").innerHTML.length == dlgLines[dlgPointer].length) { //check if text is typed out
|
||||
document.getElementById("triangle").hidden = true;
|
||||
if (dlgPointer < dlgLines.length - 1) { //check if dlgPointer is not at the array end
|
||||
if (dlgPointer < dlgLines.length - 2) { //check if dlgPointer is not at the array end
|
||||
do {
|
||||
if (String(dlgLines[dlgPointer]).startsWith("_")) {
|
||||
switch (dlgLines[dlgPointer].split(":")[0]) {
|
||||
case "_title":
|
||||
document.getElementById("title").innerHTML = dlgLines[dlgPointer].split(':')[1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
dlgPointer++;
|
||||
if (typeof dlgLines[dlgPointer] === 'number')
|
||||
speed = 50 / dlgLines[dlgPointer];
|
||||
else if (typeof dlgLines[dlgPointer] === 'object') { }
|
||||
else if (typeof dlgLines[dlgPointer] === 'string' && String(dlgLines[dlgPointer]).startsWith("_")) {
|
||||
if (dlgLines[dlgPointer].split(":")[0] === "_title")
|
||||
document.getElementById("title").innerHTML = dlgLines[dlgPointer].split(':')[1];
|
||||
}
|
||||
}
|
||||
while (typeof dlgLines[dlgPointer] !== 'string' || String(dlgLines[dlgPointer]).startsWith("_")) //again if it's not string
|
||||
typeindex = 0;
|
||||
@@ -45,6 +43,7 @@ function nextDlg() {
|
||||
typeWriter();
|
||||
} else {
|
||||
document.getElementById("bubble").hidden = true;
|
||||
document.getElementById("answer-box").hidden = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -2,9 +2,15 @@
|
||||
"start": [
|
||||
"Hello welcome to TextHorror!",
|
||||
"_title:NPC Name",
|
||||
1,
|
||||
"This is the second line",
|
||||
2,
|
||||
"Aand a third line"
|
||||
"Aand a third line",
|
||||
0.3,
|
||||
"This text is slow",
|
||||
1,
|
||||
"And again normal text",
|
||||
{
|
||||
"Yes": "CoooooooolllSADVwqavedWSDV",
|
||||
"Also Yes": "MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMGGHWhudujwd"
|
||||
}
|
||||
]
|
||||
}
|
@@ -8,6 +8,7 @@ body {
|
||||
background-color: black;
|
||||
color: white;
|
||||
font-family: pixel-font;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.thx-for-playing {
|
||||
|
Reference in New Issue
Block a user