public static void Count_Physics(Ammo_Projectile e, PointF point) { if (point.X < 0 || point.X < 0) { return; } else { float sx = e.Collision.X; float sy = e.Collision.Y; int distance = 0; decimal d = (1m / e.Speed); int delay = (int)(d * 10m); float m = point.Y / point.X; while (distance <= e.MaxDistance) { if (point.X != sx) { if (sx > point.X) { e.Collision.X -= 1; } else { e.Collision.X += 1; } } if (point.Y != sy) { if (sy > point.Y) { e.Collision.Y = -e.Collision.X * m; } else { e.Collision.Y = e.Collision.X * m; } } distance++; System.Threading.Thread.Sleep(delay); } } }
public void StartThread(PointF point) { PhysicsThread = new Thread(() => Ammo_Projectile.Count_Physics(this, point)); PhysicsThread.IsBackground = true; PhysicsThread.Start(); }