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 › random cycle sine movement
Page Index Toggle Pages: 1
random cycle sine movement (Read 442 times)
random cycle sine movement
Mar 25th, 2009, 2:01pm
 
Hello , i been trying to make wave movement with random cycles, if you dont understand what i mean i uploaded a pic,

http://www.hypermilk.net/imagenes/random_cycle.jpg

in the following example ive tried to change the "sube" value, but it doesnt work. Do anybody know how to make this or what do im making wrong?

here is the code thanks a lot


int x;
float a = 0.0;
float inc = TWO_PI/25.0;
float cambio = 0;
float sube = 0;

void  setup () {
background(162, 166, 196) ;
size (1180, 480) ;
}

void draw() {
a = a + inc;
x = x+ 1;
cambio = random(4) - 2;
sube = sube + cambio;
ellipse(x   , 228+sin(a/sube) * 26  , 33 , 33 );
println(sube) ;

}
Re: random cycle sine movement
Reply #1 - Mar 25th, 2009, 2:43pm
 
you need to keep track of a and increase it a bit every cycle, a/sube can change very fast if you change A and the frequency thus leading to some chaos.

This might be more what you're looking for :
Code:

int x;
float a = 0.0;
float inc = TWO_PI/480.0;
float cambio = 0;
float sube = 0;

float advance;

void setup () {
background(162, 166, 196) ;
size (1180, 60) ;
}

void draw() {
float ys = height/2.0+sin(a) * height/2.5;

a = a + inc*sube;
x = x + 1;
cambio = noise(x/15.0);
sube = 0.01f + cambio*80.0;
line(x-1, ys, x, height/2.0+sin(a) * height/2.5);
}

Page Index Toggle Pages: 1