xxxxxxxxxx
var thestuff;
var s = 0; // which scene am i on?
var thediv;
function preload() {
thestuff = loadJSON("adventure1.json");
}
function setup() {
createCanvas(windowWidth, windowHeight);
thediv = createDiv('this is a test');
thediv.style('font-size', '48px');
thediv.style('font-family', 'Courier');
thediv.position(50, 50);
thediv.size(width-50, height-50);
noLoop(); // turn of auto drawing
redraw();
}
function draw() {
background(255);
fill(255);
var t = thestuff.scenes[s].text;
for(let i = 0;i<thestuff.scenes[s].choices.length;i++)
{
t+="<br><br>"+"<b>"+(i+1)+"</b>" + ": " + thestuff.scenes[s].choices[i].text;
}
thediv.elt.innerHTML = t;
}
function keyPressed() {
for(let i = 0;i<thestuff.scenes[s].choices.length;i++)
{
if(key==i+1)
{
s = thestuff.scenes[s].choices[i].branch;
}
}
redraw();
}