function spawnParticle(particleX, particleY, type) {
  // Calculate time elapsed since last sound effect
  let currentTime = Date.now();
  if (currentTime - lastParticleSound > soundDelay) {
    lastParticleSound = currentTime;

    if (particleX > width() - 1) {
      particleX = width() - 1;
    }
    if (particleX < 0) {
      particleX = 0;
    }
    if (particleY > height() - 1) {
      particleY = height() - 1;
    }
    if (particleY < 0) {
      particleY = 0;
    }
    // Spawn the corresponding particle
    if (type == 0) {
      playTune(explosionSound);
      addSprite(particleX, particleY, fireParticle);
      var tempInterval = setInterval(() => {
        // Destroy particle later
        getTile(particleX, particleY).forEach((sprite) => {
          if (sprite.type == fireParticle) {
            sprite.remove();
          }
        });
        clearInterval(tempInterval);
      }, 100);
    } else if (type == 1) {
      playTune(happySound);
      addSprite(particleX, particleY, heart);
      var tempInterval = setInterval(() => {
        // Destroy particle later
        getTile(particleX, particleY).forEach((sprite) => {
          if (sprite.type == heart) {
            sprite.remove();
          }
        });
        clearInterval(tempInterval);
      }, 100);
    }
  }
}
@param {*} particleX X position of the spawned particle
@param {*} particleY Y position of the spawned particle
@param {*} type Sound type (e.g. explosion, happy)