Example #1
0
        /// <summary>
        /// Updates the floating "xna" background labels.
        /// </summary>
        public override void Update(GameTime gameTime)
        {
            time += (float)gameTime.ElapsedGameTime.TotalSeconds;

            // Spawn a new label?
            if (time > XnaSpawnRate)
            {
                FloatingXna xna = new FloatingXna();

                xna.Size = (float)random.NextDouble() * 2 + 0.5f;

                xna.Position.X = (float)random.NextDouble() * 320 + 80;
                xna.Position.Y = (float)random.NextDouble() * 700 + 50;

                floatingXnas.Add(xna);

                time -= XnaSpawnRate;
            }

            // Animate the existing labels.
            int i = 0;

            while (i < floatingXnas.Count)
            {
                FloatingXna xna = floatingXnas[i];

                xna.Age += (float)gameTime.ElapsedGameTime.TotalSeconds;

                // Different size labels move at different speeds.
                float speed = 1.5f - xna.Size;

                if (Math.Abs(speed) > 0.01f)
                {
                    xna.Position.Y -= xna.Age * xna.Age / speed / 10;
                }

                // Remove old labels.
                if (xna.Age >= XnaLifespan)
                {
                    floatingXnas.RemoveAt(i);
                }
                else
                {
                    i++;
                }
            }

            base.Update(gameTime);
        }
Example #2
0
        /// <summary>
        /// Updates the floating "xna" background labels.
        /// </summary>
        public override void Update(GameTime gameTime)
        {
            time += (float)gameTime.ElapsedGameTime.TotalSeconds;

            // Spawn a new label?
            if (time > XnaSpawnRate)
            {
                FloatingXna xna = new FloatingXna();

                xna.Size = (float)random.NextDouble() * 2 + 0.5f;

                xna.Position.X = (float)random.NextDouble() * 320 + 80;
                xna.Position.Y = (float)random.NextDouble() * 700 + 50;

                floatingXnas.Add(xna);

                time -= XnaSpawnRate;
            }

            // Animate the existing labels.
            int i = 0;

            while (i < floatingXnas.Count)
            {
                FloatingXna xna = floatingXnas[i];

                xna.Age += (float)gameTime.ElapsedGameTime.TotalSeconds;

                // Different size labels move at different speeds.
                float speed = 1.5f - xna.Size;

                if (Math.Abs(speed) > 0.01f)
                    xna.Position.Y -= xna.Age * xna.Age / speed / 10;

                // Remove old labels.
                if (xna.Age >= XnaLifespan)
                    floatingXnas.RemoveAt(i);
                else
                    i++;
            }

            base.Update(gameTime);
        }