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 & HelpSyntax Questions › upgraded code works more slowly
Page Index Toggle Pages: 1
upgraded code works more slowly (Read 802 times)
upgraded code works more slowly
May 12th, 2005, 4:37pm
 
I have upgraded the code of my sketch from the 069 version.
But it seems that the new one works more slowly.
Is it something wrong in the syntax?
Thank you for advice..

int MAX_array =1000;
int max_pix_amount = 0;
int pix_amount =0;
pix[] pix_fountain = new pix[MAX_array];
void setup() {
 size(400,400);
 framerate(30);
 for (int i = 0; i < MAX_array; i++) {
   float gray = random(255);
   pix_fountain[i] = new pix (gray,0,0,random(1,5),random(1,4));
 }
}

void draw() {
 background(255);
 pix_amount = mouseX/10;
 if (max_pix_amount < MAX_array){
   max_pix_amount += pix_amount;
 }
 if (max_pix_amount > MAX_array){
   max_pix_amount = MAX_array;
 }
 for (int i = 0; i < max_pix_amount; i++) {
   pix_fountain[i].spray();
   pix_fountain[i].check_lost();
 }
}

class pix
{
 float g;
 float xpos;
 float ypos;
 float xvel;
 float yvel;
 pix(float g_, float xp, float yp, float xv,float yv) {
   g = g_;
   xpos = xp;
   ypos = yp;
   xvel = xv;
   yvel = yv;
 }

 void spray () {
   xpos = xpos + (((mouseX/10)* xvel)/10);
   ypos = ypos + (((mouseX/10) *yvel)/10);
   point(xpos,ypos);
 }
 void check_lost () {
   if (xpos > width || ypos > height){
     xpos = 0;
   ypos = 0;}
}
}
Re: upgraded code works more slowly
Reply #1 - May 12th, 2005, 6:39pm
 
try:

size(400,400, P3D);

F

<< update >>

forgot to mention, here's why:
http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Programs;action=display;num=1115431708;start=9

F
Page Index Toggle Pages: 1