how to make things move in random curve instead of a line?
in
Programming Questions
•
11 months ago
I have the classic balls that move in a line:
- class Circle{
- float x,y,vx,vy,size;
- Circle(float ax,float ay){
- x = ax;
- y = ay;
- size = 5;
- vx = random(-.1,.1);
- vy = random(-.1,.1);
- }
- void update(int w,int h){
- x += vx;
- y += vy;
- if(x < 0 || x > w) vx *= -1;
- if(y < 0 || y > h) vy *= -1;
- }
- void draw(){
- pushStyle();
- noStroke();
- fill(0);
- ellipse(x,y,size,size);
- popStyle();
- }
- }
However, i don't want them moving in a line.
I want them moving in unregular curves. What can i add? noise? sin? cos?
Many thanks.
1