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 › speed in for-iteration
Page Index Toggle Pages: 1
speed in for-iteration (Read 378 times)
speed in for-iteration
Nov 28th, 2007, 10:11am
 
hi!

i'd like to control the speed of a for-iteration, but i don't get it how to. it should add one of those cubies at a defined amount of time to the screen. lowering the framerate is not a very nice solution, because it starts to stutter. are there other possibilities?

this is it:

 int cubies = 300;

 //in void draw()
 for (int i=0; i<cubies; i++){
   pushMatrix();
   translate(x[i], y[i], z[i]);
   noStroke();
   c[i].create(quadBG[i]);
   x[i]+=xSpeed[i];
   y[i]+=ySpeed[i];
   z[i]+=zSpeed[i];
   popMatrix();
 }

thanks a lot!

regards,
daniel
Re: speed in for-iteration
Reply #1 - Nov 28th, 2007, 10:48am
 
the more things you render the lower the framerate will get. that you can run from.

as for rendering or adding a cubbie every n'th second its up to you to change the count of cubbies to render.

this will increase number of cubbies to render every 3 seconds.

// @ mainloop
float time = (millis() - currTime) * 0.001;
if( time >= 3.0 )
{
currTime = millis();
counter ++;
}

//in void draw()
for (int i=0; i<counter; i++)
{
   pushMatrix();
   translate(x[i], y[i], z[i]);
   noStroke();
   c[i].create(quadBG[i]);
   x[i]+=xSpeed[i];
   y[i]+=ySpeed[i];
   z[i]+=zSpeed[i];
   popMatrix();
}
Re: speed in for-iteration
Reply #2 - Nov 28th, 2007, 11:05am
 
yipee!! Wink
thanks a lot! works great.
Page Index Toggle Pages: 1