xxxxxxxxxx
// THEN 1304, 1305
var jsonn; // a file format common in open data system
var scenee = 0; // which scene is on
function preload() {
jsonn = loadJSON("adventure1.json");
}
function setup() {
createCanvas(windowWidth, windowHeight);
textSize(40);
}
function draw() {
background(100);
fill(255);
var t = jsonn.scenes[scenee].text;
text(t, 50, 100);
for(let i = 0;i < jsonn.scenes[scenee].choices.length;i++)
{
text(i+1 + ": " + jsonn.scenes[scenee].choices[i].text, 50, 200 + 40*i);
}
}
function keyPressed() {
for(let i = 0;i < jsonn.scenes[scenee].choices.length;i++)
{
if(key==i+1)
{
scenee = jsonn.scenes[scenee].choices[i].branch;
}
}
}