DarkTornado

Update Particle

Jun 4th, 2011
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1.         //Update
  2.         public void Update(GameTime gameTime)
  3.         {
  4.             //Update timer.
  5.             timer += (int)gameTime.ElapsedGameTime.TotalMilliseconds;
  6.             if (timer >= lifeTime)
  7.             {
  8.                 _remove = true;
  9.             }
  10.             //Update properties.
  11.             speedUpdater.Update(gameTime); //Speed.
  12.             directionUpdater.Update(gameTime); //Direction.
  13.             rotationUpdater.Update(gameTime); //Rotation.
  14.             sizeUpdater.Update(gameTime); //Size.
  15.             float currentSpeed = speedUpdater.GetValue(); //Calculate and save the speed.
  16.             float currentDirection = directionUpdater.GetValue(); //Calculate and save the direction.
  17.             //Update position.
  18.             position.X += currentSpeed * (float)Math.Cos(currentDirection / 180 * Math.PI) * (float)gameTime.ElapsedGameTime.TotalSeconds;
  19.             position.Y += currentSpeed * (float)Math.Sin(currentDirection / 180 * Math.PI) * (float)gameTime.ElapsedGameTime.TotalSeconds;
  20.         }
Advertisement
Add Comment
Please, Sign In to add comment