public void Draw(ClusterPlayer observer) { double m = observer.Magnification; Vector obs = observer.Position; Color c = Brightness * Math.Pow(m, 0.3) * Colors.White; IGraphics g = observer.Output.Graphics; Vector p = Position.Translated(-obs).Scaled(m).ToOrigin(); g.PPoint(c, p); }
public void Draw(ClusterPlayer observer) { double m = observer.Magnification; Vector obs = observer.Position; Color c = Colors.Blue; IGraphics g = observer.Output.Graphics; Vector p1 = Position.Translated(-obs).Scaled(m).ToOrigin(); Vector p2 = (Position - Velocity.Normalized * length).Translated(-obs).Scaled(m).ToOrigin(); g.LLine(c, p1, p2); }
public void PlayerPositions(Random rand, IReadOnlyList <ClusterPlayer> players) { for (int i = 0; i < players.Count; i++) { bool foundplace = false; int counter = 0; ClusterPlayer player = players[i]; double size = player.Size; Vector p = new Vector(0, 0); while (!foundplace) { bool valid = true; p = new Vector(normDouble(rand, 0, Constants.World.SigmaX), normDouble(rand, 0, Constants.World.SigmaY)); foreach (Planet planet in Planets) { double d = (planet.Position - p).Length - (planet.Radius + size); if (d < Constants.World.MinD) { valid = false; } } for (int j = 0; j < i; j++) { double d = (players[j].Position - p).Length - (players[j].Size + size); if (d < Constants.World.MinD) { valid = false; } } if (valid) { foundplace = true; } counter++; if (counter > 100000) { throw new Exception("Too many iterations to find a place for the planet"); } } player.Position = p; } }
public void Collide(ClusterPlayer other) { if ((other.Position - Position).LengthBBox < other.Size + Size && (other.Position - Position).Length < other.Size + Size) { Vector dv = Velocity - other.Velocity; Vector dx = Position - other.Position; double fullMass = Mass + other.Mass; Velocity -= 2 * other.Mass / fullMass * Vector.Dot(dv, dx) / dx.SquaredLength * dx; other.Velocity += 2 * Mass / fullMass * Vector.Dot(-dv, -dx) / dx.SquaredLength * dx; } }
public void Draw(ClusterPlayer observer) { double m = observer.Magnification; double r = Radius * m; if (r > 0.5) { Vector obs = observer.Position; Color c = Colors.White; IGraphics g = observer.Output.Graphics; Vector p = Position.Translated(-obs).Scaled(m).ToOrigin(); g.CCircle(c, p, r); } }
public void Draw(ClusterPlayer observer) { Vector obs = observer.Position; double m = observer.Magnification; IGraphics g = observer.Output.Graphics; foreach (Star star in Stars) { star.Draw(observer); } foreach (Planet planet in Planets) { planet.Draw(observer); } }
public void Draw(ClusterPlayer observer) { Vector p = Position - observer.Position; double m = observer.Magnification; IGraphics g = observer.Output.Graphics; if (true) { foreach (Segment part in Ship) { Segment seg = part.Scaled(Size).Rotated(Angle).Translated(p).Scaled(m).ToOrigin(); g.LLine(LocalColor, seg.Start, seg.End); } if (Weapon == 0) { foreach (Segment part in Gun) { Segment seg = part.Scaled(Size).Rotated(Angle).Translated(p).Scaled(m).ToOrigin(); g.LLine(LocalColor, seg.Start, seg.End); } } foreach (LBeam lbeam in LBeams) { lbeam.Draw(observer); } } if (Constants.Debug) { g.CCircle(LocalColor, p.Scaled(m).ToOrigin(), View * m); g.LLine(LocalColor, p.Scaled(m).ToOrigin(), (p + 5 * Heading).Scaled(m).ToOrigin()); g.LLine(Colors.Blue, p.Scaled(m).ToOrigin(), (p + 5 * Velocity.Normalized).Scaled(m).ToOrigin()); } }