Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="args"></param>
        public override void Update(TickEventArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            this.X += (int)(args.SecondsElapsed * 10 * dx);
            this.Y += (int)(args.SecondsElapsed * 10 * dy);

            // Adjust our entropy
            dx += SpriteRandomizer.Next(-5, 6);
            dy += SpriteRandomizer.Next(-5, 6);

            // Call the base which also normalizes the bounds
            base.Update(args);

            // Normalize the directions
            if (this.X == SpriteBounds.Left)
            {
                dx = SpriteRandomizer.Next(1, 11);
            }

            if (this.X == SpriteBounds.Right)
            {
                dx = ((-1) * SpriteRandomizer.Next(1, 11));
            }

            if (this.Y == SpriteBounds.Top)
            {
                dy = SpriteRandomizer.Next(1, 11);
            }

            if (this.Y == SpriteBounds.Bottom)
            {
                dy = ((-1) * SpriteRandomizer.Next(1, 11));
            }
        }
Beispiel #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="surfaces"></param>
 /// <param name="rect"></param>
 /// <param name="coordinates"></param>
 public BounceSprite(SurfaceCollection surfaces, Rectangle rect, Vector coordinates)
     : base(surfaces, rect, coordinates)
 {
     this.dx = SpriteRandomizer.Next(-10, 11);
     this.dy = SpriteRandomizer.Next(-10, 11);
 }