Basically this program is supposed to read a file (like the one I will post in a reply), and display the scenes in a text-based adventure game with images. The idea is for people to then be able to upload the files to my website so that people can play them. Right now, though, it does not display the images for some reason and does not switch frames.
Quote:/**Adventure Reader*/
PImage[] view;
int frame;
String[] inventory;
int numInvent;
String[] adventure;
String[] options;
String[] conditions;
int[] next;
int loopCount;
void setup() {
size(600,600);
background(0);
view=new PImage[3];
String loadPath=selectInput();
adventure=loadStrings(loadPath);
inventory=new String[10];
println(adventure[0]);
print("You have:");
inventory=split(adventure[2],',');
numInvent=int(adventure[1]);
for(int i=0;i<numInvent;i++) {
if(i>0) {
print(',');
}
print(inventory[i]);
}
println(" ");
println(adventure[3]);
frame=1;
loopCount=1;
inventory=expand(inventory,50);
}
void draw() {
background(0);
noLoop();
// print("You have:");
// for(int i=0;i<numInvent;i++) {
// if(i>0) {
// print(',');
// }
// print(inventory[i]);
// }
String[] images;
while(frame != 999) {
images=split(adventure[5+(frame*8)],',');
view[0]=loadImage(images[0]);
view[1]=loadImage(images[1]);
view[2]=loadImage(images[2]);
if(adventure[8+(frame*8)]!=null) {
if(numInvent<=50) {
inventory[numInvent]=adventure[7+(frame*8)];
numInvent=numInvent+1;
}
}
println(adventure[6+(frame*8)]);
print("Your options are:");
print(adventure[7+(frame*8)]);
println("");
options=split(adventure[9+(frame*8)],',');
conditions=split(adventure[10+(frame*8)],',');
next=int(split(adventure[11+(frame*8)],','));
image(view[0],0,0);
image(view[1],200,0);
image(view[2],400,0);
loopCount=loopCount+1;
while(!keyPressed) {
image(view[0],0,0);
image(view[1],200,0);
image(view[2],400,0);
}
print(conditions[0]);
print(conditions[1]);
print(conditions[2]);
print(next[0]);
print(next[1]);
print(next[2]);
print(options[0]);
print(options[1]);
print(options[2]);
print(frame);
print(images[0]);
print(images[1]);
print(images[2]);
for(int i=0; i<next.length; i++) {
if(str(key) == options[i]) {
loopCount=1;
if(conditions[i]=="x") {
frame=next[i];
}
else if(conditions[i]=="rnd") {
if(int(random(1,3))==2) {
frame=next[i];
}
}
else if(conditions[i]=="rndx") {
if(int(random(1,3))==2) {
frame=next[i];
}
else {
frame=0;
}
}
else {
for (int j=0;j<numInvent;j++) {
if(inventory[j]==conditions[i]) {
frame=next[i];
}
}
}
}
}
}
}