Processing3 1.随机行走

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)); //0,1,2,or 3
if(choice == 0) {
x++;
} else if(choice == 1) {
x--;
} else if(choice == 2) {
y++;
} else {
y--;
}
}
} Walker walker;
void setup() {
size(640,360);
walker = new Walker();
background(255);
}
void draw() {
walker.setup();
walker.display();
}
上一篇:后缀数组---Musical Theme


下一篇:ccf 再买菜 搜索 dfs