Ejemplo n.º 1
0
        private void WallCollision(Particle pi)
        {
            float x = 0;
            float y = 0;

            if (pi.Position.X > (_worldWidth / 2 - Wpadding))
                x -= (pi.Position.X - (_worldWidth / 2 - Wpadding)) / CollisionForce;
            else if (pi.Position.X < (-_worldWidth / 2 + Wpadding))
                x += ((-_worldWidth / 2 + Wpadding) - pi.Position.X) / CollisionForce;

            if (pi.Position.Y > (_worldHeight - Hpadding))
                y -= (pi.Position.Y - (_worldHeight - Hpadding)) / CollisionForce;
            else if (pi.Position.Y < Hpadding)
                y += (Hpadding - pi.Position.Y) / CollisionForce;

            pi.Velocity.X += x;
            pi.Velocity.Y += y;
        }
Ejemplo n.º 2
0
 public Spring2(Particle pa, Particle pb, float restLength)
 {
     PA = pa;
     PB = pb;
     RestLength = restLength;
 }
Ejemplo n.º 3
0
 public bool Contains(Particle p)
 {
     return (PA.GetHashCode() == p.GetHashCode() || PB.GetHashCode() == p.GetHashCode());
 }
Ejemplo n.º 4
0
 private void ApplyGravity(Particle particle)
 {
     particle.Velocity.Set(particle.Velocity.X + Gravity.X, particle.Velocity.Y + Gravity.Y);
 }