We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Images and Stuff not appearing
Page Index Toggle Pages: 1
Images and Stuff not appearing (Read 423 times)
Images and Stuff not appearing
May 10th, 2009, 6:20am
 
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];
            }
          }
        }
      }
    }
  }
}










Re: Images and Stuff not appearing
Reply #1 - May 10th, 2009, 6:21am
 
Here's my adventure:

Code:
The Mad Caves by Jonah
2
sword,flask
You have just fallen into a large cave system. Scattered around are pools of blue, glowing liquid.
#Die
black.jpg,herodie1.jpg,black.jpg
You have fallen.
Continue(a)

a
x
1
#1
leftcave.jpg,enemy1.jpg,rightcave.jpg
In front of you stands a sneaky-looking girl with dark skin, fangs, black hair, claws and pointed ears.
Move forward(w), kill catgirl(y), use sword(n)

w,y,n
x,x,sword
2,0,3
#2
black.jpg,twistypassage.jpg,black.jpg
There is a long, twisty passage in front of you.
Move forward(w)

w
x
0
#3
leftCave.jpg,enemy1.jpg,rightCave.jpg
The girl flinches.
Move forward(w), kill catgirl(y)

w,y
x,x
2,2
Page Index Toggle Pages: 1