Esempio n. 1
0
ScreenData::ScreenData(QObject *parent) : QObject(parent)
{
    getScreenResolution();
    CalculateRatio();

    QScreen *mScreen = QApplication::screens().at(0);
    connect(mScreen, SIGNAL(orientationChanged(Qt::ScreenOrientation)), this, SLOT(Orientation(Qt::ScreenOrientation)));
}
void CEmiter::AnimateParticles(void)
{
  FLOAT tmNow=_pTimer->CurrentTick();
  INDEX ctCount=em_aepParticles.Count();
  INDEX iCurrent=0;
  while( iCurrent<ctCount)
  {
    CEmittedParticle &ep=em_aepParticles[iCurrent];
    // not yet alive
    if(ep.ep_tmEmitted<0)
    {
      iCurrent++;
    }
    // if shouldn't live any more
    else if( tmNow>ep.ep_tmEmitted+ep.ep_tmLife)
    {
      CEmittedParticle &emLast=em_aepParticles[ctCount-1];
      ep=emLast;
      ctCount--;
    }
    // it is alive, animate it
    else
    {
      // animate position
      ep.ep_vLastPos=ep.ep_vPos;
      ep.ep_vSpeed=ep.ep_vSpeed+em_vG*_pTimer->TickQuantum;
      ep.ep_vPos=ep.ep_vPos+ep.ep_vSpeed*_pTimer->TickQuantum;
      // animate rotation
      ep.ep_fLastRot=ep.ep_fRot;
      ep.ep_fRot+=ep.ep_fRotSpeed*_pTimer->TickQuantum;
      // animate color
      FLOAT fRatio=CalculateRatio(tmNow, ep.ep_tmEmitted, ep.ep_tmEmitted+ep.ep_tmLife, 1, 0);
      ep.ep_colLastColor=ep.ep_colColor;
      iCurrent++;
    }
  }
  if( em_aepParticles.Count()==0)
  {
    em_aepParticles.PopAll();
  }
  else if( em_aepParticles.Count()!=ctCount)
  {
    em_aepParticles.PopUntil(ctCount-1);
  }
}