assassin-bug/src/engine/output.js

26 lines
761 B
JavaScript
Raw Normal View History

2021-11-04 19:58:37 +00:00
import { TTS } from '../framework/tts';
import { AriaOutput } from '../framework/tts/outputs/aria';
2021-11-05 13:28:01 +00:00
import Sound from './sound';
2021-11-04 19:58:37 +00:00
export default class Output {
constructor() {
this.tts = new TTS(new AriaOutput());
this.history = document.getElementById("output-area");
2021-11-05 13:28:01 +00:00
this.sound = new Sound();
2021-11-04 19:58:37 +00:00
}
say(string) {
2021-11-05 13:28:01 +00:00
this.sound.play(`assets/scroll.wav`);
2021-11-04 19:58:37 +00:00
const node = document.createElement("p");
2021-11-04 23:02:02 +00:00
string.split("\n").forEach((line) => {
node.appendChild(document.createTextNode(line));
node.appendChild(document.createElement("br"));
});
2021-11-04 19:58:37 +00:00
this.history.appendChild(node);
// this.tts.speak(string);
}
2021-11-05 13:28:01 +00:00
play(file) {
this.sound.play(file);
}
2021-11-04 19:58:37 +00:00
}