finished answer branching
This commit is contained in:
@@ -16,10 +16,10 @@
|
|||||||
<p id="dlg-text"></p>
|
<p id="dlg-text"></p>
|
||||||
</div>
|
</div>
|
||||||
<div hidden="true" id="answer-box">
|
<div hidden="true" id="answer-box">
|
||||||
<p class="answer"></p>
|
<p class="answer" id="0" onclick="answered(this.id)"></p>
|
||||||
<p class="answer"></p>
|
<p class="answer" id="1" onclick="answered(this.id)"></p>
|
||||||
<p class="answer"></p>
|
<p class="answer" id="2" onclick="answered(this.id)"></p>
|
||||||
<p class="answer"></p>
|
<p class="answer" id="3" onclick="answered(this.id)"></p>
|
||||||
</div>
|
</div>
|
||||||
<img draggable="false" hidden="true" id="triangle" src="text_horror/assets/triangle.png">
|
<img draggable="false" hidden="true" id="triangle" src="text_horror/assets/triangle.png">
|
||||||
<p class="thx-for-playing">Thanks for playing</p>
|
<p class="thx-for-playing">Thanks for playing</p>
|
||||||
|
@@ -13,6 +13,14 @@ function load() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function changeDlg(dlgKey) {
|
||||||
|
dlgPointer = 0;
|
||||||
|
typeindex = 0;
|
||||||
|
dlgLines = dlgFile[dlgKey];
|
||||||
|
document.getElementById("dlg-text").innerHTML = "";
|
||||||
|
typeWriter();
|
||||||
|
}
|
||||||
|
|
||||||
function typeWriter() {
|
function typeWriter() {
|
||||||
if (document.getElementById("dlg-text").innerHTML.length < dlgLines[dlgPointer].length) {
|
if (document.getElementById("dlg-text").innerHTML.length < dlgLines[dlgPointer].length) {
|
||||||
document.getElementById("dlg-text").innerHTML += dlgLines[dlgPointer].charAt(typeindex);
|
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 (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
|
if (dlgPointer < dlgLines.length - 1) { //check if dlgPointer is not at the array end
|
||||||
do {
|
do {
|
||||||
|
dlgPointer++;
|
||||||
if (typeof dlgLines[dlgPointer] === 'number')
|
if (typeof dlgLines[dlgPointer] === 'number')
|
||||||
speed = 50 / dlgLines[dlgPointer];
|
speed = 50 / dlgLines[dlgPointer];
|
||||||
else if (typeof dlgLines[dlgPointer] === 'object') {
|
else if (typeof dlgLines[dlgPointer] === 'object') {
|
||||||
@@ -43,7 +52,6 @@ function nextDlg() {
|
|||||||
if (dlgLines[dlgPointer].split(":")[0] === "_title")
|
if (dlgLines[dlgPointer].split(":")[0] === "_title")
|
||||||
document.getElementById("title").innerHTML = dlgLines[dlgPointer].split(':')[1];
|
document.getElementById("title").innerHTML = dlgLines[dlgPointer].split(':')[1];
|
||||||
}
|
}
|
||||||
dlgPointer++;
|
|
||||||
}
|
}
|
||||||
while (!(typeof dlgLines[dlgPointer] === 'string') || dlgLines[dlgPointer].startsWith("_")) //again if it's not string
|
while (!(typeof dlgLines[dlgPointer] === 'string') || dlgLines[dlgPointer].startsWith("_")) //again if it's not string
|
||||||
if (typeof dlgLines[dlgPointer] === 'string') {
|
if (typeof dlgLines[dlgPointer] === 'string') {
|
||||||
@@ -58,8 +66,10 @@ function nextDlg() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeDlg(dlgKey = "") {
|
function answered(answerId) {
|
||||||
var dlgPointer = 0;
|
console.log(typeof dlgLines[dlgPointer] === 'object');
|
||||||
dlgLines = dlgFile[dlgKey];
|
dlgFile = dlgLines[dlgPointer];
|
||||||
typeWriter();
|
document.getElementById("bubble").addEventListener("click", nextDlg);
|
||||||
|
document.getElementById("answer-box").hidden = true;
|
||||||
|
changeDlg(document.getElementById(answerId).innerHTML);
|
||||||
}
|
}
|
@@ -9,10 +9,28 @@
|
|||||||
"Can you answer?",
|
"Can you answer?",
|
||||||
{
|
{
|
||||||
"Yes": [
|
"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": [
|
"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!"
|
||||||
|
]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Reference in New Issue
Block a user