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.
Page Index Toggle Pages: 1
wierd behaivor (Read 469 times)
wierd behaivor
Apr 1st, 2006, 1:33pm
 
hello people, theres something wierd with some processing code i been working this afternoon maybe somebody can help me.... i dont know why  when i run the exe file (exported application) it runs very slow, but when i run the code from the processing environment it runs fast... can anybody tell me what is happening?
here is the code:


int div = 20;
int num = 10;
float gX =10;
float gY = 10;
float grax =500;
float gray = 500;
Ball[] balls;

void setup()
{
 size(500,500);
 smooth();
 framerate(60);
 reset();
}

void draw()
{
 background(141,63,158);
 if ( mousePressed == true )
 {
   gX = 500;
   gY = 100;
 }


 for ( int i=0; i<num; i++ )
 {
   balls[i].gravitate(gX, gY);
//   balls[i].repulse();
   balls[i].move();
   balls[i].display();
  balls[i].tiempol();
   }
 
 
 
}

void reset()
{
 balls = new Ball[num];

 for ( int i=0; i<num; i++ )
 {
   balls[i] = new Ball(random(0,width), random(0,height),"A",grax,gray);
 }

}


class Ball
{
 float vmax;
 float amax;
 float rmax;
 float x;
 float y;
 float vX;
 float vY;
 String type;
  int xo;
   int yo;
   int xxx;
   int yyy;
 
  float tiempo = 3000;
   int lastRun= 0;
  //  lastRun=0;
 
 Ball(float X, float Y, String Type, float grax, float gray)
 {
     
 
   
   
   
       float xf=random(grax);
float yf=random(gray);
 xxx= int(xf);
 yyy= int(yf);
//print(x);
   
   type = Type;
   if ( type == "A" )
   {
     vmax = 3;
   }
   else
   {
     vmax = 1;
   }
   amax = 0.4;
   rmax = 0.14;
   x = X;
   y = Y;
   vX = 0;
   vY = 0;
 }
 

void tiempol(){
     int m=millis();
   //  print(m);
 if(m>=(lastRun+3000))
 {
  lastRun=m;
  tiempo= random(3000);
//  print(tiempo);
       float xf=random(500);
float yf=random(500);
 xxx= int(xf);
 yyy= int(yf);
}
 
 
 
}
   
 
 void display()
 {
   if ( type == "A" )
   {
     stroke(255,255,255);
   }
   else
   {  
     stroke(0,0,0);
   }
   strokeWeight(vmax+1);
   point(x,y);
   strokeWeight(1);
  // line(x,y,x-2*vX,y-2*vY);
 }
 
 void gravitate(float gX, float gY)
 {
    //   float xf=random(gX);
// float yf=random(gY);
// xo= int(xf);
// yo= int(yf);
// print(yo);
   float theta = atan((yyy-y)/(xxx-x));
   float aX = abs(xxx-x)/(xxx-x)*amax*cos(theta)*abs(xxx-x)/1000;
   float aY = abs(yyy-y)/(yyy-y)*sqrt(pow(amax,2)-pow(aX,2))*abs(yyy-y)/1000;
   
   vX = aX + vX;
   vY = aY + vY;
   
   truncate();
 }
 
 void truncate()
 {
   if ( sqrt(pow(vX,2)+pow(vY,2)) > vmax )
   {
     float theta = atan(vY/vX);
     vX = abs(vX)/vX*vmax*cos(theta);
     vY = abs(vY)/vY*sqrt(pow(vmax,2)-pow(vX,2));
   }
 }
 

 
 void move()
 {
   x = vX + x;
   y = vY + y;
 }
}


Re: wierd behaivor
Reply #1 - Apr 1st, 2006, 1:35pm
 
 background(141,63,157);
Re: wierd behaivor
Reply #2 - Apr 1st, 2006, 8:02pm
 
any chance you're using the version of processing that includes java but have java 1.5 installed elsewhere on your machine?
Re: wierd behaivor
Reply #3 - Apr 1st, 2006, 11:06pm
 
yes , im using the processing version that includes java and i also hav java 1.5 installed in my harddrive... should i uninstall java 1.5?
Re: wierd behaivor
Reply #4 - Apr 2nd, 2006, 12:04am
 
try copying the "java" subfolder to the application.windows directory, then re-run the app and see if it's back at the faster speed.
Re: wierd behaivor
Reply #5 - Apr 2nd, 2006, 1:18am
 
i just copied but it doesnt work its still slow, is this a bug?
maybe is because im on windows 98

Page Index Toggle Pages: 1