function splitAsteroid(at) {
  let funcToUse = (a,b) => b;
  switch (Math.floor(Math.random() * 3)) {
    case 0: funcToUse = rot; break;
    case 1: funcToUse = sideways; break;
    case 2: funcToUse = forwards; break;
  }
  if(at.size > minAsteroidSize) {
    asteroids.push(
      new Asteroid(
        at.pos,
        conj(mt(funcToUse(1), inv(at.pos)), forwards(0.002 + 0.007 * Math.random())),
        at.size * 0.75
      ),
      new Asteroid(
        at.pos,
        conj(mt(funcToUse(-1), inv(at.pos)), forwards(0.002 + 0.007 * Math.random())),
        at.size * 0.75
      )
    )
  }

  for (let i = 0; i < 10; i++) {
    particles.push(new Particle(at.pos));
  }

  music.asteroidHit++;

}
// When the asteroid collides with bullets, or the player.
When the asteroid collides with bullets, or the player.
When the asteroid collides with bullets or the player .
function splitAsteroid(at) {
  let funcToUse = (a,b) => b;
  switch (Math.floor(Math.random() * 3)) {
    case 0: funcToUse = rot; break;
    case 1: funcToUse = sideways; break;
    case 2: funcToUse = forwards; break;
  }
  if(at.size > minAsteroidSize) {
    asteroids.push(
      new Asteroid(
        at.pos,
        conj(mt(funcToUse(1), inv(at.pos)), forwards(0.002 + 0.007 * Math.random())),
        at.size * 0.75
      ),
      new Asteroid(
        at.pos,
        conj(mt(funcToUse(-1), inv(at.pos)), forwards(0.002 + 0.007 * Math.random())),
        at.size * 0.75
      )
    )
  }
  for (let i = 0; i < 10; i++) {
    particles.push(new Particle(at.pos));
  }
  music.asteroidHit++;
}
function splitAsteroid ( at ) { let funcToUse = ( a , b ) => b ; switch ( Math . floor ( Math . random ( ) * 3 ) ) { case 0 : funcToUse = rot ; break ; case 1 : funcToUse = sideways ; break ; case 2 : funcToUse = forwards ; break ; } if ( at . size > minAsteroidSize ) { asteroids . push ( new Asteroid ( at . pos , conj ( mt ( funcToUse ( 1 ) , inv ( at . pos ) ) , forwards ( 0.002 + 0.007 * Math . random ( ) ) ) , at . size * 0.75 ) , new Asteroid ( at . pos , conj ( mt ( funcToUse ( - 1 ) , inv ( at . pos ) ) , forwards ( 0.002 + 0.007 * Math . random ( ) ) ) , at . size * 0.75 ) ) } for ( let i = 0 ; i < 10 ; i ++ ) { particles . push ( new Particle ( at . pos ) ) ; } music . asteroidHit ++ ; }
When the asteroid collides with bullets, or the player.
When the asteroid collides with bullets or the player .