public static List <Vector2> CalcCircleCollisionPoints(float radius, float minLength) { float minTheta = MathsExt.CalcMinTheta(radius, minLength); List <Vector2> relativeCollisionPoints = new List <Vector2>(); for (float theta = 0; theta <= 2 * Math.PI - minTheta; theta += minTheta) { relativeCollisionPoints.Add(Mechanics.VectorComponents(radius, theta)); } return(relativeCollisionPoints); }
private Vector2 ApplyDamping(Vector2 vector) { Vector2 dampedVelocity = vector *= _friction; if (Mechanics.VectorMagnitude(dampedVelocity) < 16f) { return(Vector2.Zero); } else { return(dampedVelocity); } }
public void ResolveCollisions(bool[,] collisionMap, GameTime gameTime) { List <Vector2> collidingPoints = Collision.CheckCollision(collisionMap, transformedPolyPoints); if (collidingPoints.Count > 0) { collided = true; stable = true; Vector2 response = Collision.CalculateResponseVector(collidingPoints, _potential); Vector2 reflection = Mechanics.ReflectionVector(velocity, response); UpdateResponseVelocity(ApplyDamping(reflection), gameTime); UpdateCollisionPoints(position, rotation); if (Collision.CheckCollision(collisionMap, transformedPolyPoints).Count != 0) { UpdateResponseVelocity(reflection, gameTime); } } else { collided = false; stable = false; UpdateRealPosition(); } }
public void ThrowAgain(float power, float angle, Vector2 initialPosition) { inMotion = true; position = initialPosition; velocity = Mechanics.VectorComponents(power, angle); }
public Fireball(Vector2 initialPosition, float throwPower, float throwAngle) : base(initialPosition, MASS, FRICTION, true, _minCollisionPolyPointDistance) { velocity = Mechanics.VectorComponents(throwPower, throwAngle); inMotion = true; }