class Marble { float radius; float[] x,y,z; float xm=0, ym=0, zm=0; int TRACE_LENGTH=5; Marble(float _radius, float _spd) { radius = _radius; float rd=random(TWO_PI); xm=_spd*cos(rd); zm=_spd*sin(rd); x=new float[TRACE_LENGTH]; y=new float[TRACE_LENGTH]; z=new float[TRACE_LENGTH]; } void centerOn(Terrain _ter) { for (int i=0;i0;i--) { x[i]=x[i-1]; y[i]=y[i-1]; z[i]=z[i-1]; } } void move(Terrain _ter) { xm+=random(-0.1,0.1); zm+=random(-0.1,0.1); ym+=0.2; if (x[0]+xm-radius<0||x[0]+xm+radius>=_ter.fullWid) xm*=-1; if (z[0]+zm-radius<0||z[0]+zm+radius>=_ter.fullDep) zm*=-1; shiftTail(); x[0]+=xm; z[0]+=zm; y[0]+=ym; float ylim = _ter.getAltitudeAt(x[0],z[0]); if (y[0]>ylim) { y[0] -= (y[0]-ylim); ym*=-0.4; } //y[0] = _ter.getAltitudeAt(x[0],z[0]); } void draw() { //noStroke(); //fill(255,0,0); //pushMatrix(); //translate(x,y-radius,z); //sphere(radius); //box(radius); //stroke(255,255,255,128); for (int i=0;i