ktyl.dev/src/vn/main.js
2024-03-07 00:23:26 +00:00

64 lines
3.3 KiB
JavaScript

let idx = 0
let frames = [
"press start to begin!", "img/kt/stargazer.png", "start",
"hello! you're just in time!", "img/kt/yay.png", null,
"this was starting to get ridiculous.", "img/kt/you-shouldnt-be-doing-that.png", null,
"there are books EVERYWWHERE", "img/kt/scared.png", null,
"and more keep coming!", "img/kt/oshit.png", null,
"we've got to do something about them at some point, why not now?", "img/kt/determined.png", null,
"hey, could you sort the books for me?", "img/books-messy.png", "stack by size",
"yes, i can you've finished STACKING them,", "img/books-size.png", null,
"but that's hardly FINISHED, is it?", "img/books-size.png", null,
"i mean sure, if you want to be a pedant about it they're sort of ordered by size,", "img/kt/nonplussed.png", null,
"but they're still just piled up in the same place, what's that supposed to change?", "img/kt/coffee.png", null,
"why don't you try again?", "img/books-size.png", "push stack over",
"", "img/books-messy.png", "order books by colour",
"", "img/books-colour.png", null,
"no, colours won't work either.", "img/kt/dreamer0.png", null,
"why?", "img/kt/blast.png", null,
"simple, i don't do colours.", "img/kt/grin.png", null,
"it's nothing personal, they're just not for me, you know?", "img/kt/glad-you-asked.png", "restart"
];
function setText(text) {
document.getElementById('text-box-content').innerHTML = text;
}
function setImage(path) {
document.getElementById('portrait').src = path;
}
function setButtonText(text) {
console.log(text);
if (text == null) {
text = "next";
}
document.getElementById('button-text').innerHTML = text;
}
function advance() {
const stride = 3;
if (idx >= frames.length) {
idx = 0;
}
let text = frames[idx];
let img = frames[idx + 1];
let buttonText = frames[idx + 2];
setText(text);
setButtonText(buttonText);
setImage(img);
idx += stride;
}