level 1
wjzwys
楼主
int h1, h2, jump;
int numVerts = 56;
int[] x = new int[numVerts];
int[] y = new int[numVerts];
void setup() {
size(600, 400);
h1 = 300;
h2 = 100;
jump = 20;
assignVertices();
}
void draw() {
background(255);
for (int i = 0; i < numVerts-1; i++) line(x[i], y[i], x[i+1], y[i+1]);
}
void assignVertices() {
int currWidth = 0;
int currHeight = h1;
for (int i = 0; i < numVerts; i++) {
if (i%2 == 0) currWidth += jump;
if (i%4 == 1) currHeight = h2;
if (i%4 == 3) currHeight = h1;
x[i] = currWidth;
y[i] = currHeight;
}
}
2015年05月14日 02点05分
1
int numVerts = 56;
int[] x = new int[numVerts];
int[] y = new int[numVerts];
void setup() {
size(600, 400);
h1 = 300;
h2 = 100;
jump = 20;
assignVertices();
}
void draw() {
background(255);
for (int i = 0; i < numVerts-1; i++) line(x[i], y[i], x[i+1], y[i+1]);
}
void assignVertices() {
int currWidth = 0;
int currHeight = h1;
for (int i = 0; i < numVerts; i++) {
if (i%2 == 0) currWidth += jump;
if (i%4 == 1) currHeight = h2;
if (i%4 == 3) currHeight = h1;
x[i] = currWidth;
y[i] = currHeight;
}
}