-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocessing.pde
46 lines (44 loc) · 1.03 KB
/
processing.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
int cols = 0;
int rows = 0;
int scl = 20;
int w = 3000;
int h = 3000;
float[][] terrain;
void setup() {
fullScreen(P3D);
cols = w / scl;
rows = h / scl;
terrain = new float[rows][cols];
}
float flying = 0;
void generate_terrain() {
float yoff = flying -= 0.01;
for (int y = 0; y < rows; ++y) {
float xoff = 0;
for (int x = 0; x < cols; ++x) {
terrain[y][x] = map(noise(xoff,yoff),0,1, -2,300);
xoff += 0.1;
}
yoff += 0.1;
}
background(#87CEEB);
noStroke();
fill(#FFE87C);
ellipse(1860,10,300,300);
stroke(#4B4D55);
fill(#686D76);
translate(width / 2,height);
rotateX(PI / 2);
translate( -width / 2 - 570, -height);
for (int y = 0; y < rows - 1; y++) {
beginShape(TRIANGLE_STRIP);
for (int x = 0; x < cols; x++) {
vertex(x * scl, y * scl,terrain[y][x]);
vertex(x * scl,(y + 1) * scl,terrain[y + 1][x]);
}
endShape();
}
}
void draw() {
generate_terrain();
}