noise walking line back and forth

trying to turn this circle into a line (point) that will walk back and forth across the screen. This is where I'm at, knowing it's way off in a strange direction. Please help.

color bgColor = color(0); // black
color drawColor = color(255, 255, 255, 255); // white
float t = 0;
float n = noise(t);
float x = map (n, 0,1,0,width);
float y = map (n, 0,1,0,height);

void setup() {
  size(900, 650);
  background(bgColor);
}

void draw () {

  ellipse (x, 31,14,14);

  t += 0.01;
}

  class Walker {
    float x,y;

    float tx,ty;

    Walker() {
      tx = 0;
      ty = 10000;
    }

    void step() {
      x = map(noise(tx), 0, 1, 0, width);
      y = map(noise(tx), 0, 1, 0, height);

      tx += 0.01;
      ty += 0.01;
    }
  }
Tagged:

Answers

  • where do you use ty?

  • I thought that was time * y-coordinate. This may be an example of how lost I am?

  • Did you read the tutorial on oop now? Oop means object oriented programming.

    You have a class walker but don't use it.

    Also you should have background at the start of draw()

  • Anyway t will just increase all the time

    Your description is also very short

    Do you want line or point? Do you want to generate a curve? Left or downwards?

    To make progress say

    x= radius * sin(t) + 120;

    Read on sin in Wikipedia

  • This is how you'd get the walker the work. Click to create new walkers.

    color bgColor = color(0); // black
    color drawColor = color(255, 255, 255, 255); // white
    
    ArrayList<Walker> walkers; // list/container for Walker instances
    
    void setup() {
      size(900, 650);
    
      walkers = new ArrayList<Walker>(); // create an empty list
    }
    
    void draw () {
    
      background(bgColor);
    
      //cycle through the list of walkers (0 at first)
      for (int i = 0; i < walkers.size(); i++) {
        // see this variable as a windows shortcut to the walkers stored
        // in the walkers arraylist
    
        Walker shortcutToWalker = walkers.get(i); 
    
        // update the walker
        shortcutToWalker.step(); // this will call the actual walkers step() function
    
        // draw the walker
        fill(drawColor);
        ellipse(shortcutToWalker.x, shortcutToWalker.y, 14, 14);
      }
    }
    
    void mouseReleased()
    {
      // make new walker
      Walker newWalker = new Walker();
      walkers.add(newWalker);
    }
    
    
    class Walker {
      float x, y;
    
      float tx, ty;
    
      Walker() {
        tx = 0;
        ty = 10000;
      }
    
      void step() {
        x = map(noise(tx), 0, 1, 0, width);
        y = map(noise(ty), 0, 1, 0, height);
    
        tx += 0.01;
        ty += 0.01;
      }
    }
    
Sign In or Register to comment.