have a recurring event every x seconds

this should get you started..

unsigned long balls = 0;
unsigned long lastBall = 0;

void setup()
{
  Serial.begin(115200);
}

void loop()
{
  if ( millis() - lastBall > 3000)
  {
    if (ballReady() && motorsRunning())
    {
       lastBall = millis();   
       shootBall();
       balls++;
       Serial.print("time : ");
       Serial.print(lastBall );
       Serial.print("\t\t balls : ");
       Serial.print(balls);
       Serial.print("\t\t average: ");
       Serial.print(lastBall/balls);
    }
  }

  // other code can be here
} 

bool ballReady()
{
  return true; // need improvement
}

bool motorsRunning()
{
  return true;  // need improvement
}

void shootBall()
{
  Serial.print("shoot !"); // need improvement
}