function Lucioles(nb) {

  var a = new Array();
  var tx,ty;
  
  this.majTaille = function()
  {
    tx = largeur_fenetre()-10;
    ty = hauteur_fenetre()-10;
  }
  
  this.majTaille();
  
  for (var i=0; i<nb; i++)
  {
    var v = (Math.random()+0.3)*3;
    var ang = Math.random()*Math.PI*2;
    a.push({x: Math.random()*tx, y: Math.random()*ty, dx: Math.cos(ang)*v, dy: Math.sin(ang)*v, t: Math.random()*Math.PI, dt: (Math.random()+0.2)*0.03});
  }
  
  this.afficher = function()
  {
    for (var i=0; i<a.length; i++)
    {
      var info = a[i], img;
      if (!info.img) {
        img = cE("img");
        this.myImgLoaded = false;
        img.onload = function () {
          this.myImgLoaded = true;
        }
        img.src = "images/luciole.png";
        img.style.position = "absolute";
        img.style.zIndex = 100;
        img.className = "pngfix";
        document.body.appendChild(img);
        info.img = img;
      }
      img = info.img;
      img.style.display = (img.myImgLoaded?"block":"none");
      img.style.left = Math.round(info.x-10)+"px";
      img.style.top = Math.round(info.y-10)+"px";
    }
  }

  this.cacher = function()
  {
    for (var i=0; i<a.length; i++)
    {
      var info = a[i], img;
      if (info.img) info.img.style.display = "none";
    }
  }
  
  this.bouger = function()
  {
    this.majTaille();  
    for (var i=0; i<a.length; i++)
    {
      var info = a[i];
      info.x += info.dx + info.dy*Math.sin(info.t);
      info.y += info.dy - info.dx*Math.sin(info.t);
      info.t += info.dt;
      if (info.x < 10) { info.x = 10; info.dx = Math.abs(info.dx); }
      if (info.y < 10) { info.y = 10; info.dy = Math.abs(info.dy); }
      if (info.x > tx) { info.x = tx; info.dx = -Math.abs(info.dx); }
      if (info.y > ty) { info.y = ty; info.dy = -Math.abs(info.dy); }
    }
    this.afficher();
  }
  
  this.afficher();  

}
