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 › Sketch doesn't work once exported
Page Index Toggle Pages: 1
Sketch doesn't work once exported (Read 995 times)
Sketch doesn't work once exported
Jul 26th, 2005, 5:55pm
 
Hope this is the right forum, anyway this is my first piece of processing beyond just "ohh look a line" so its probably quite a mess and maybe a few things I don't need but anyway works as intended in the enviroment but only the drawing works in a browser.

Anyone got any idea why? Cheers

left mouse:draw
right mouse:delete


Version 0091 Windows XP

---------------------------------
Code:

int maxdrops = 3000;
Water[] drops = new Water[maxdrops];
int numdrops = 1;

void setup(){
 size(400,400);
 colorMode(RGB);
 background(0);
}

void draw(){
 //Tap
 if(numdrops<maxdrops){
   drops[numdrops] = new Water(200,0);
   numdrops++;
 }
 //Paint
 if(mousePressed) {
   if(mouseButton == LEFT){
   //Draw
       stroke(100,174,81);
       strokeWeight(8);
       line(mouseX, mouseY, pmouseX, pmouseY);
       strokeWeight(1);
   }
   //Erase
    if(mouseButton == RIGHT){
              stroke(0);
       strokeWeight(8);
       line(mouseX, mouseY, pmouseX, pmouseY);
       strokeWeight(1);
    }
   }
   for (int i = 1; i < numdrops; i++) {
     //int selected = min((int)random(numdrops), numdrops - 1);
     drops[i].update();
   }

 
}

class Water {
 int xpos,ypos,lastx,lasty,nextx,nexty,left,right,decide;
 
 Water (int x, int y) {
   xpos = x;
   ypos = y;
 }
 
 void update() {
   //make last
   this.lastx = this.xpos;
   this.lasty = this.ypos;
   //check down
   if(get(this.xpos,this.ypos+1) == -16777216){

     this.nextx = this.xpos;
     this.nexty = this.ypos;
     this.nexty++;
   } else {
   //check left and right
     this.decide = int(random(2));
     if(this.decide == 0){
     //left
         if(get(this.xpos-1,ypos) == -16777216){
         this.nextx = this.xpos;
         this.nexty = this.ypos;
         this.nextx--;
         }
     //end
     }
     if(this.decide == 1){
     //right
         if(get(this.xpos+1,ypos) == -16777216){
         this.nextx = this.xpos;
         this.nexty = this.ypos;
         this.nextx++;
         }
     //end
     }
   
   }
     //send to top
     if((this.xpos == 200) && (this.ypos == 399) && (numdrops >= 1000)){
       this.nextx = 201;
       this.nexty = 0;
     }
   //delete last
   stroke(0,0,0);
   point(this.lastx,this.lasty);
   //make new
   stroke(0,172,255);
   point(this.nextx,this.nexty);
   //current position
   this.xpos = this.nextx;
   this.ypos = this.nexty;
 }

}

Re: Sketch doesn't work once exported
Reply #1 - Jul 26th, 2005, 8:29pm
 
Code:

Water[] drops = new Water[maxdrops];


Try initializing this in setup().
Re: Sketch doesn't work once exported
Reply #2 - Jul 27th, 2005, 11:32am
 
Thanks for the reply, tried moving that in to setup but I get
"Semantic Error: No accessible field named "drops" was found"
as soon as it reaches
Code:
"drops[numdrops] = new Water(200,0);" 


at the start of draw.
Re: Sketch doesn't work once exported
Reply #3 - Jul 27th, 2005, 3:49pm
 
I think you want:

Code:

Water[] drops;

void setup()
{
size(...);
drops=new Water[maxdrops];
...
}
Re: Sketch doesn't work once exported
Reply #4 - Jul 27th, 2005, 4:58pm
 
Ahh yeah I see, that one works the same in the dev environment. However the same result when exported, drawing and deleting works but no water.
Re: Sketch doesn't work once exported
Reply #5 - Jul 28th, 2005, 1:03am
 
check the java console for any errors from within the browser. if you're using windows, this will be accessible somewhere from the goofy java icon that shows up in your tray when running in the browser, or on the mac, use Applications -> Utilities -> Console and see what sort of errors you're getting.
Re: Sketch doesn't work once exported
Reply #6 - Jul 28th, 2005, 1:04am
 
and to add to that, you may need to flush your browser's cache, or the java applet cache, and/or quit and restart the browser completely because it may be using the broken version of your code even after re-exporting.

or simpler, try changing the name before the next export.
Re: Sketch doesn't work once exported
Reply #7 - Jul 28th, 2005, 11:14am
 
No messages in the console (windows) and tried clearing both caches and disabled the java one resaved the file with a colour change so I would know its the new code but still the same results.

Is there any quirks I could be encountering that would cause this or is it most likely something wrong in my code?
Page Index Toggle Pages: 1