示例#1
0
void CChunkParticle::update(int ticks)
{
	age += ticks;
	if (age >= lifetime) {
		if (destroyAnimation) {
			CPosition p(pos.x, calculateScreenPos(pos.y, height));
			GraphicAnimation *destroyanimation = destroyAnimation->clone();
			//Wyrmgus start
//			StaticParticle *destroy = new StaticParticle(p, destroyanimation, destroyDrawLevel);
			StaticParticle *destroy = new StaticParticle(p, this->MapLayer, destroyanimation, destroyDrawLevel);
			//Wyrmgus end
			ParticleManager.add(destroy);
		}

		destroy();
		return;
	}

	const int minSmokeTicks = 150;
	const int randSmokeTicks = 50;

	if (age > nextSmokeTicks) {
		CPosition p(pos.x, calculateScreenPos(pos.y, height));
		GraphicAnimation *smokeanimation = smokeAnimation->clone();
		//Wyrmgus start
//		CSmokeParticle *smoke = new CSmokeParticle(p, smokeanimation, 0, -22.0f, smokeDrawLevel);
		CSmokeParticle *smoke = new CSmokeParticle(p, MapLayer, smokeanimation, 0, -22.0f, smokeDrawLevel);
		//Wyrmgus end
		ParticleManager.add(smoke);

		nextSmokeTicks += MyRand() % randSmokeTicks + minSmokeTicks;
	}

	debrisAnimation->update(ticks);
	if (debrisAnimation->isFinished()) {
		GraphicAnimation *debrisanimation = debrisAnimation->clone();
		delete debrisAnimation;
		debrisAnimation = debrisanimation;
	}

	float time = age / 1000.f;

	float distance = getHorizontalPosition(initialVelocity, trajectoryAngle, time);
	pos.x = initialPos.x + distance * direction.x;
	pos.y = initialPos.y + distance * direction.y;

	height = getVerticalPosition(initialVelocity, trajectoryAngle, time);
}
示例#2
0
CExtent TextStruct::getTextBox(double spaceRatio, double penWidth) const
{
   const double characterSpacing = .1; 
   const double textLeading = 1.25;

   double boxWidth = getMaxLineLength(spaceRatio,penWidth);

   int numLines = getNumLines();

   double boxHeight = m_height + ((numLines - 1) * textLeading * m_height);

   CPoint2d upperLeft(0.,0.);

   switch (getVerticalPosition())
   {
   case verticalPositionBaseline:  upperLeft.y = m_height;      break;
   case verticalPositionCenter:    upperLeft.y = boxHeight/2.;  break;
   case verticalPositionBottom:    upperLeft.y = boxHeight;     break;
   case verticalPositionTop:       upperLeft.y = 0.;            break;
   }

   switch (getHorizontalPosition())
   {
   case horizontalPositionLeft:    upperLeft.x = 0.;           break;
   case horizontalPositionCenter:  upperLeft.x = -boxWidth/2.; break;
   case horizontalPositionRight:   upperLeft.x = -boxWidth;    break;
   }

   CPoint2d lowerRight = upperLeft + CPoint2d(boxWidth,-boxHeight);

   if (m_oblique != 0)
   {
      double offset = m_height * cos(degreesToRadians(m_oblique));

      if (offset < 0.) upperLeft.x  -= offset;
      else             lowerRight.x += offset;
   }

   CExtent textBox;

   textBox.update(upperLeft);
   textBox.update(lowerRight);

   return textBox;
}