Exemplo n.º 1
0
        private void ProceedPhysics(ICollider collider)
        {
            var avgSpeed = (collider.Velocity + Velocity) / 2;

            if (collider.Static || Static)
            {
                avgSpeed.Zero();
            }
            if (collider.MovableStatic)
            {
                avgSpeed = collider.Velocity;
            }

            var intersection = RectangleF.Intersect(PredictCollider(this), collider.CollideRectangle);

            if (Math.Abs(intersection.Height - intersection.Width) < 5)
            {
                return;
            }
            var intersectionType = GetIntersectionType(PredictCollider(this), collider.CollideRectangle);

            if (intersectionType == IntersectionType.Top)
            {
                if (!collider.MovableStatic)
                {
                    collider.MovePhysics(colliders);
                    collider.Move(colliders);
                }
                ProceedFriction(collider);
            }
            else if (intersectionType != IntersectionType.Bottom)
            {
                collider.Velocity = new PointF(avgSpeed.X, collider.Velocity.Y);
            }
        }