2D Terrain Deformation
in
Share your Work
•
3 years ago
- //2010 Devan Buggay
- float[][] ground= new float[250][3];
- void setup(){
- frameRate(60);
- size(500,500);
- strokeWeight(2);
- }
- void draw(){
- background(255);
- for(int i=1;i<(width/2);i++){
- stroke(100,50,50);
- line(i*2,ground[i][0]+300,i*2,height);
- line(((i-1)*2),ground[i-1][0]+300,i*2,ground[i][0]+300);
- }
- println(frameRate);
- }
- void deform(float x){
- for(int i=1;i<(width/2);i++){
- int r=abs(int(x)-i);
- ground[i][0]+=500/(500+exp(r));
- }
- }
- void mousePressed(){
- deform(mouseX/2);
- }