コード例 #1
0
        public Player(Texture2D texture, Vector2 position, Game game)
        {
            CurrentTexture = texture;
            Position       = position;
            bounds         = new BoundingCircle(Position, 16f);

            trailingFX = new PixieParticleSystem(game, this);
            game.Components.Add(trailingFX);
        }
コード例 #2
0
        /// <summary>
        /// Detection a collision between a circle and a rectangle
        /// </summary>
        /// <param name="c"></param>
        /// <param name="r"></param>
        /// <returns>true for collision, false otherwise</returns>
        public static bool Collides(BoundingCircle c, BoundingRectangle r)
        {
            float nearestX = MathHelper.Clamp(c.Center.X, r.Left, r.Right);
            float nearestY = MathHelper.Clamp(c.Center.Y, r.Top, r.Bottom);

            return(Math.Pow(c.Radius, 2) >=
                   Math.Pow(c.Center.X - nearestX, 2) +
                   Math.Pow(c.Center.Y - nearestY, 2));
        }
コード例 #3
0
 public Orb(Texture2D texture, Portal portal, float radius, float speed, float startAngle)
 {
     bounds         = new BoundingCircle(Vector2.Zero, 16f);
     CurrentTexture = texture;
     this.portal    = portal;
     Position       = portal.Position;
     this.radius    = radius;
     this.speed     = speed;
     angle          = startAngle;
 }
コード例 #4
0
 /// <summary>
 /// Tests for a collision between this and another bounding circle
 /// </summary>
 /// <param name="other"></param>
 /// <returns>true if collision, false otherwise</returns>
 public bool CollidesWith(BoundingCircle other)
 {
     return(CollisionHelper.Collides(this, other));
 }
コード例 #5
0
 public static bool Collides(BoundingRectangle r, BoundingCircle c) => Collides(c, r);
コード例 #6
0
 /// <summary>
 /// Detects a collision between two BoundingCircles
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b"></param>
 /// <returns>true for collision, false otherwise</returns>
 public static bool Collides(BoundingCircle a, BoundingCircle b)
 {
     return(Math.Pow(a.Radius + b.Radius, 2) >=
            Math.Pow(a.Center.X - b.Center.X, 2) +
            Math.Pow(a.Center.Y - b.Center.Y, 2));
 }