class BounceBall extends Ball { float FRICTION = 0.99; BounceBall(int ix, int iy, float ivx, float ivy, float iradius) { //use Ball's constructor, cuz thats good enuf super(ix,iy,ivx,ivy,iradius); } void update() { vx*=FRICTION; vy*=FRICTION; super.update(); limit(); } void limit() { if (y>height-radius) { vy=-vy; y=constrain(y,-height*height, height-radius); } if ((x>radius) || (x>width-radius)) { vx=vx; x=constrain(x, radius, width-radius); } } void display() { fill (random(255), random(255),random(255)); super.display(); } }