1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GenerativeArt Part1

Last updated at Posted at 2019-03-17

#ランダムウォーク
void stepの
choiceによってランダムに選択された4方向をつかってdotを描いていくコード

##実行結果
スクリーンショット 2019-03-18 1.53.12.png

##code

randomWalk_1.pde
class Walker{
  int x;
  int y;

  Walker(){
    x = width/2;
    y = height/2;
  }
  
  void display(){
    stroke(0);
    point(x,y);
  }
  
  void step(){
    int choice = int(random(4));
    
    if(choice == 0){
      x++;
    }else if (choice == 1){
      x--;
    }else if (choice == 2){
      y++;
    }else{
      y--;
    }
  }
}


Walker w;

void setup(){
  size(640,360);
  w = new Walker();
  background(255);
}

void draw(){
  w.step();
  w.display();
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?