Example #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sprite"></param>
 /// <param name="positionX"></param>
 /// <param name="positionY"></param>
 /// <param name="velocity"></param>
 public ParticleSprite(Sprite sprite, float positionX, float positionY, Vector velocity)
 {
     this.X = positionX;
     this.Y = positionY;
     this.Velocity = velocity;
     m_Sprite = sprite;
 }
Example #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="surfaces"></param>
        /// <param name="bounds"></param>
        /// <param name="coordinates"></param>
        public BoundedSprite(SurfaceCollection surfaces, Rectangle bounds, Vector coordinates)
            : base(surfaces, coordinates)
        {
            if (surfaces == null)
            {
                throw new ArgumentNullException("surfaces");
            }
            this.bounds = bounds;
            int tempHeight;
            int tempWidth;
            tempWidth = this.bounds.Size.Width - (int)surfaces.Size.Width;
            tempHeight = this.bounds.Size.Height - (int)surfaces.Size.Height;
            this.bounds.Size = new Size(tempWidth, tempHeight);
            base.Frame = rand.Next(surfaces.Count);
            if (rand.Next(2) % 2 == 0)
            {
                this.AnimateForward = true;
            }
            else
            {
                this.AnimateForward = false;
            }

            this.Animate = true;
        }
Example #3
0
        ///// <summary>
        ///// Creates a new AnimatedSprite from a surface collection and a name
        ///// </summary>
        ///// <param name="name">The name of the animation</param>
        ///// <param name="surfaces">The surface collection containing the frames of the animation.</param>
        //public AnimatedSprite(string name, SurfaceCollection surfaces)
        //    : this(surfaces, new Vector(0, 0, 0))
        //{
        //    this.CurrentAnimation = name;
        //}

        /// <summary>
        /// Creates a new AnimatedSprite from a surface collection and a name
        /// </summary>
        /// <param name="name">The name of the animation</param>
        /// <param name="surfaces">The surface collection containing the frames of the animation.</param>
        /// <param name="vector">Vector of sprite</param>
        public AnimatedSprite(string name, SurfaceCollection surfaces, Vector vector)
            : base(surfaces, vector)
        {
            this.m_CurrentAnimation = name;
            m_Timer.Elapsed += new System.Timers.ElapsedEventHandler(m_Timer_Elapsed);
            m_Timer.Interval = m_Animations[m_CurrentAnimation].Delay;
            //this.CurrentAnimation = name;
            AnimationCollection animation = new AnimationCollection();
            animation.Add(surfaces);
            m_Animations.Add(name, animation);
        }
Example #4
0
 /// <summary>
 /// Creates a particle surface.
 /// </summary>
 /// <param name="surface"></param>
 /// <param name="positionX"></param>
 /// <param name="positionY"></param>
 /// <param name="velocity"></param>
 public ParticleSurface(Surface surface, float positionX, float positionY, Vector velocity)
 {
     if (surface == null)
     {
         throw new ArgumentNullException("surface");
     }
     m_Surface = surface;
     this.X = positionX;
     this.Y = positionY;
     this.Velocity = velocity;
     m_ClipRectangle = new Rectangle(0, 0, m_Surface.Width, m_Surface.Height);
 }
 public EffectDie(Color colour, KillableSprite kS)
 {
     xDirRange = new Vector (new PointF (-1.0f, 2.0f));
     yDirRange = new Vector (new PointF (-1.0f, -1.0f));
     xSpeedRange = new Vector (new Point (150, 200));
     ySpeedRange = new Vector (new Point (150, 200));
     numberRange = new Vector (new Point (100, 200));
     xStopRange = new Vector (new Point ((int)(kS.width*1.1), kS.width*2));
     yStopRange = new Vector (new Point ((int)(kS.height*1.1), kS.height*2));//(Tile.HEIGHT - 5, Tile.HEIGHT-2));
     newParticlesNumberRange = new Vector (new Point (0, 0));
     newParticlesTimeRange = new Vector (new PointF (0, 0));
     alpha = 255;
     alphaStep = -200;
     repeat = false;
     graphics = new Graphic[]{new Graphic(colour, WIDTH, HEIGHT), new Graphic(Color.Red, WIDTH, HEIGHT)};
     Vector blank = new Vector (0);
     template = new ParticleOptions (blank, blank, xDirRange, yDirRange, xSpeedRange, ySpeedRange, numberRange,
         xStopRange,yStopRange, newParticlesTimeRange, newParticlesNumberRange, alpha, alphaStep, repeat, graphics);
 }
 public EffectFire()
 {
     xDirRange = new Vector (new PointF (-0.5f, 0.5f));
     yDirRange = new Vector (new Point (-1, -1));
     xSpeedRange = new Vector (new Point (0, 0));
     ySpeedRange = new Vector (new Point (100, 600));
     numberRange = new Vector (new Point (8, 10));
     xStopRange = new Vector (new Point (Tile.WIDTH, Tile.WIDTH));
     yStopRange = new Vector (new Point (1, 20));//(Tile.HEIGHT - 5, Tile.HEIGHT-2));
     newParticlesNumberRange = new Vector (new Point (1, 6));
     newParticlesTimeRange = new Vector (new PointF (0.01f, 0.34f));
     alpha = 255;
     alphaStep = -200;
     repeat = true;
     graphics = new Graphic[]{new Graphic(Color.Orange, WIDTH, HEIGHT), new Graphic(Color.Red, WIDTH, HEIGHT),
         new Graphic(Color.Yellow, WIDTH,HEIGHT)};
     Vector blank = new Vector (0);
     template = new ParticleOptions (blank, blank, xDirRange, yDirRange, xSpeedRange, ySpeedRange, numberRange,
         xStopRange, yStopRange, newParticlesTimeRange, newParticlesNumberRange, alpha, alphaStep, repeat, graphics);
 }
        public ParticleOptions(Vector _xPosRange, Vector _yPosRange, Vector _xDirRange, Vector _yDirRange, Vector _xSpeedRange,
			Vector _ySpeedRange, Vector _numberRange, Vector _xStopRange, Vector _yStopRange, Vector _newParticlesTimeRange, 
			Vector _newParticlesNumberRange, int _alpha, int _alphaStep, bool _repeat, Graphic[] _graphics)
        {
            xPosRange = _xPosRange;
            yPosRange = _yPosRange;
            xDirRange = _xDirRange;
            yDirRange = _yDirRange;
            xSpeedRange = _xSpeedRange;
            ySpeedRange = _ySpeedRange;
            numberRange = _numberRange;
            xStopRange = _xStopRange;
            yStopRange = _yStopRange;
            newParticlesTimeRange = _newParticlesTimeRange;
            newParticlesNumberRange = _newParticlesNumberRange;
            alpha = _alpha;
            alphaStep = _alphaStep;
            repeat = _repeat;
            graphics = _graphics;
            graphicRange = new Vector (new Point (0, graphics.Length));
        }
Example #8
0
 /// <summary>
 /// Create new sprite
 /// </summary>
 /// <param name="vector">Vector of Sprite</param>
 /// <param name="surface">Surface of Sprite</param>
 /// <param name="group">
 /// SpriteCollection group to put Sprite into.
 /// </param>
 public Sprite(Surface surface, Vector vector, SpriteCollection group)
     : this(surface, vector)
 {
     if (group == null)
     {
         throw new ArgumentNullException("group");
     }
     group.Add(this);
 }
Example #9
0
 /// <summary>
 /// Creates a new ParticlePixel.
 /// </summary>
 /// <param name="color"></param>
 /// <param name="positionX"></param>
 /// <param name="positionY"></param>
 /// <param name="velocity"></param>
 /// <param name="life"></param>
 public ParticlePixel(Color color, float positionX, float positionY, Vector velocity, int life)
 {
     this.Velocity = velocity;
     this.X = positionX;
     this.Y = positionY;
     m_Color = color;
     Life = life;
     LifeFull = life;
 }
Example #10
0
 /// <summary>
 /// Creates a new ParticlePixel.
 /// </summary>
 /// <param name="color"></param>
 /// <param name="velocity"></param>
 public ParticlePixel(Color color, Vector velocity)
 {
     this.Velocity = velocity;
     m_Color = color;
 }
Example #11
0
 public SolidEntity(Sprite sprite, float x, float y, Vector vector, int life)
     : base(sprite, x, y, vector, life)
 {
     this.currentCollisions = new List<SolidEntity>();
 }
Example #12
0
 /// <summary>
 /// Find the distance between two SolidEntity objects.
 /// </summary>
 /// <param name="entity1">The first entity.</param>
 /// <param name="entity2">The second entity.</param>
 /// <returns>
 /// The distance (in pixels) between the centers of the two objects.
 /// </returns>
 public static double GetDistance(SolidEntity entity1, SolidEntity entity2)
 {
     // Create a vector between the two entities to find the distance.
     Vector v = new Vector(entity1.Center, entity2.Center);
     return v.Length;
 }
Example #13
0
 /// <summary>
 /// Creates a particle surface.
 /// </summary>
 /// <param name="surface"></param>
 /// <param name="clip"></param>
 /// <param name="positionX"></param>
 /// <param name="positionY"></param>
 /// <param name="velocity"></param>
 public ParticleSurface(Surface surface, Rectangle clip, float positionX, float positionY, Vector velocity)
 {
     if (surface == null)
     {
         throw new ArgumentNullException("surface");
     }
     m_ClipRectangle = clip;
     m_Surface = surface;
     this.X = positionX;
     this.Y = positionY;
     this.Velocity = velocity;
 }
Example #14
0
 /// <summary>
 /// Creates a new vector based on the given length and direction (in degrees) with a length of 1.
 /// </summary>
 /// <param name="directionDeg">The direction of the vector in degrees.</param>
 /// <returns>The newly created vector.</returns>
 public static Vector FromDirection(int directionDeg)
 {
     Vector vec = new Vector(directionDeg);
     vec.Length = 1;
     return vec;
 }
Example #15
0
 /// <summary>
 /// Creates a new vector based on the given length and direction (in degrees).
 /// </summary>
 /// <param name="directionDeg">The direction of the vector in degrees.</param>
 /// <param name="length">The length of the vector.</param>
 /// <returns>The newly created vector.</returns>
 public static Vector FromDirection(int directionDeg, float length)
 {
     Vector vec = new Vector(directionDeg);
     vec.Length = length;
     return vec;
 }
Example #16
0
 /// <summary>
 /// Returns a new vector equal to the normalized version of this one.
 /// </summary>
 /// <returns>
 /// A new vector representing the normalized vector.
 /// </returns>
 public Vector Normalized()
 {
     Vector ret = new Vector(this);
     ret.Normalize();
     return ret;
 }
Example #17
0
 /// <summary>
 /// Calculates the reflection angle of the current 
 /// vector using the given normal vector.
 /// </summary>
 /// <param name="normal">
 /// The normal angle.
 /// </param>
 /// <returns>
 /// A new vector representing the reflection angle.
 /// </returns>
 /// <remarks>
 /// Make sure the length of the vector is 1 or it will 
 /// have an effect on the resulting vector.
 /// </remarks>
 public Vector Reflection(Vector normal)
 {
     return this - (2 * this.DotProduct(normal) * normal);
 }
Example #18
0
 /// <summary>
 /// Creates a new vector based on the given direction (in radians) with a length of 1.
 /// </summary>
 /// <param name="directionRadians">The direction of the vector in radians.</param>
 /// <returns>The newly created vector.</returns>
 public static Vector FromDirection(float directionRadians)
 {
     Vector vec = new Vector(directionRadians);
     vec.Length = 1;
     return vec;
 }
Example #19
0
 /// <summary>
 /// Find the angle between two SolidEntity objects.
 /// </summary>
 /// <param name="entity1">The first (origin) entity.</param>
 /// <param name="entity2">The second (destination) entity.</param>
 /// <returns>
 /// The degree of the angle between the centers of the two entities
 /// (with entity1's center as the origin).
 /// </returns>
 public static int GetDirectionDeg(SolidEntity entity1, SolidEntity entity2)
 {
     // Create a vector between the two entities to find the angle.
     Vector v = new Vector(entity1.Center, entity2.Center);
     return Convert.ToInt32(Math.Truncate(v.DirectionDeg));
 }
Example #20
0
 /// <summary>
 /// Addition operator
 /// </summary>
 /// <param name="vector"></param>
 /// <param name="scalar"></param>
 /// <returns></returns>
 public static Vector Add(Vector vector, float scalar)
 {
     return new Vector(vector.m_x + scalar, vector.m_y + scalar, vector.m_z + scalar);
 }
Example #21
0
        /* Note: SDL.NET provides the Vector struct which is composed of an
         * origin point, a direction, and a magnitude (length). Vectors are
         * used to specify particle velocity, but they also make handy
         * abstractions for a few generally useful tasks (see below).
         */
        /// <summary>
        /// Calculate a screen position given various information.
        /// </summary>
        /// <param name="startingPosition">The origin position.</param>
        /// <param name="angleDeg">The angle in degrees.</param>
        /// <param name="distancePixels">The distance in pixels.</param>
        /// <returns>
        /// The position that lies the specified distance from the specified
        /// position, at the specified angle.
        /// </returns>
        public static Point GetPosition(Point startingPosition, int angleDeg, int distancePixels)
        {
            // Create a vector with the specified angle and length.
            Vector offsetVector = Vector.FromDirection(angleDeg, distancePixels);

            // Add the two vectors.
            Vector resultVector = new Vector(startingPosition.X, startingPosition.Y, 0) + offsetVector;

            // Return the resulting position.
            return resultVector.Point;
        }
Example #22
0
 /// <summary>
 /// Minus operator
 /// </summary>
 /// <param name="vector"></param>
 /// <param name="scalar"></param>
 /// <returns></returns>
 public static Vector Subtract(Vector vector, float scalar)
 {
     return new Vector(vector.m_x - scalar, vector.m_y - scalar, vector.m_z - scalar);
 }
Example #23
0
 /// <summary>
 /// Creates a new ParticlePixel.
 /// </summary>
 /// <param name="color"></param>
 /// <param name="positionX"></param>
 /// <param name="positionY"></param>
 /// <param name="velocity"></param>
 public ParticlePixel(Color color, float positionX, float positionY, Vector velocity)
 {
     this.Velocity = velocity;
     this.X = positionX;
     this.Y = positionY;
     m_Color = color;
 }
Example #24
0
 /// <summary>
 /// Multiplication operator
 /// </summary>
 /// <param name="vector"></param>
 /// <param name="scalar"></param>
 /// <returns></returns>
 public static Vector Multiply(Vector vector, float scalar)
 {
     return new Vector(vector.m_x * scalar, vector.m_y * scalar, vector.m_z * scalar);
 }
Example #25
0
 /// <summary>
 /// Creates a new ParticlePixel.
 /// </summary>
 /// <param name="positionX">The X coordinate.</param>
 /// <param name="positionY">The Y coordinate.</param>
 /// <param name="velocity">The speed and direction of the particle.</param>
 public ParticlePixel(float positionX, float positionY, Vector velocity)
 {
     this.Velocity = velocity;
     this.X = positionX;
     this.Y = positionY;
 }
Example #26
0
 /// <summary>
 /// Division operator
 /// </summary>
 /// <param name="vector"></param>
 /// <param name="scalar"></param>
 /// <returns></returns>
 public static Vector Divide(Vector vector, float scalar)
 {
     return new Vector(vector.m_x / scalar, vector.m_y / scalar, vector.m_z / scalar);
 }
Example #27
0
 /// <summary>
 /// Create new Sprite
 /// </summary>
 /// <param name="vector">Vector of Sprite</param>
 /// <param name="surface">Surface of Sprite</param>
 public Sprite(Surface surface, Vector vector)
 {
     if (surface == null)
     {
         throw new ArgumentNullException("surface");
     }
     this.surf = surface;
     this.vector = vector;
 }
Example #28
0
 /// <summary>
 /// Gets the dot product of the current vector along with the given one.
 /// </summary>	
 /// <param name="other">The other vector to use when getting the dot product.</param>
 /// <returns>The dot product of the two vectors.</returns>
 public float DotProduct(Vector other)
 {
     return (m_x * other.m_x) + (m_y * other.m_y) + (m_z * other.m_z);
 }
Example #29
0
 internal Sprite(SurfaceCollection surfaces, Vector vector)
 {
     if (surfaces == null)
     {
         throw new ArgumentNullException("surfaces");
     }
     this.surf = surfaces[0];
     this.vector = vector;
 }
Example #30
0
 /// <summary>
 /// Gets the midpoint between the two vectors.
 /// </summary>
 /// <param name="vector">The other vector to compare this one to.</param>
 /// <returns>A new vector representing the midpoint between the two vectors.</returns>
 public Vector Midpoint(Vector vector)
 {
     //if (vector == null)
     //{
     //    throw new ArgumentNullException("vector");
     //}
     return new Vector((m_x + vector.X) * 0.5, (m_y + vector.Y) * 0.5, (m_z + vector.Z) * 0.5);
 }