直接用splice()去掉出界的小球
function updateBalls(){
for( var i = 0 ; i < balls.length ; i ++ ){
balls[i].x += balls[i].vx;
balls[i].y += balls[i].vy;
balls[i].vy += balls[i].g;
if( balls[i].y >= WINDOW_HEIGHT-RADIUS ){
balls[i].y = WINDOW_HEIGHT-RADIUS;
balls[i].vy = - balls[i].vy*0.75;
}
if(balls[i].x<-RADIUS || balls[i].x>WINDOW_WIDTH+RADIUS){
balls.splice(i,1);
}
}
}