xxxxxxxxxx
var thestuff;
var s = 0; // which scene am i on?
function preload() {
thestuff = loadJSON("adventure1.json");
}
function setup() {
createCanvas(windowWidth, windowHeight);
background(100);
console.log(thestuff);
textSize(40);
}
function draw() {
background(0);
fill(255);
var t = thestuff.scenes[s].text;
text(t, 50, 100);
for(let i = 0;i<thestuff.scenes[s].choices.length;i++)
{
text(i+1 + ": " + thestuff.scenes[s].choices[i].text, 50, 200 + 40*i);
}
}
function keyPressed() {
for(let i = 0;i<thestuff.scenes[s].choices.length;i++)
{
if(key==i+1)
{
s = thestuff.scenes[s].choices[i].branch;
}
}
}