-
Notifications
You must be signed in to change notification settings - Fork 0
How to use
Mike edited this page Jun 12, 2021
·
5 revisions
<head>
<link rel="stylesheet" href="TextGameEngine-styles.css">
</head>
import { TextGameEngine, Titles } from "./TextGameEngine.js";
const tge = new TextGameEngine();
tge.init();
tge.print("Welcome to the Text Game!");
tge.print("New Paragraph", true);
tge.print(); //Empty line
If you don't use await you wont get player answer
const num = await tge.num();
const text = await tge.text();
Don't forget about await
const options = ["Red", "Blue", "Green"];
const index = await tge.choose(options);
const chosen = options[index];
await is also required
await tge.wait(); // until the player clicks continue
await tge.wait(2); // two second pause
tge.clear(); // remove all lines
tge.clear(5); // remove 5 lines
When you write functions, don't forget about await and async
async function askQuestion(question: string)
{
tge.print(question);
const answer = await tge.text();
return answer;
}
tge.print("Hello!")
const answer = await askQuestion("Enter your name:");
You can add html to the info popup
const infDiv = tge.getInfDiv();
const div = document.createElement("div");
infDiv.appendChild(div);
div.innerText = "A game about a brave knight and a beautiful princess";
tge.openInf();