Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program new;
- {$R-}
- const
- SPEEDSCALE := 500;
- G = 6.674*10**-11;
- Middle: TPoint = [500,500];
- type
- TPlanet = record
- Distance, Diameter, Mass: Double;
- Pos: record Distance, Angle: Single; end;
- Color: TColor;
- pathrad: Int32;
- end;
- var
- Sun: TPlanet;
- image: TImage;
- Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, Neptune: TPlanet;
- year: Int32;
- function TPlanet.Velocity(): Double;
- begin
- Result := Sqrt((G*Sun.Mass) / (Self.Distance*1000));
- end;
- function TPlanet.SizeScaled(): Int32;
- begin
- Result := Max(1,Trunc(Self.Diameter ** 0.35 / 5));
- end;
- function TPlanet.Tick(Image: TImage): TPoint;
- var
- speed: Single;
- size: Int32;
- begin
- speed := Self.Velocity();
- size := Self.SizeScaled();
- if Self.Diameter = Earth.Diameter then
- begin
- if Modulo(Self.Pos.Angle + speed/Self.Distance*speedscale, 2*PI) <> Self.Pos.Angle + speed/Self.Distance*speedscale then
- year += 1;
- Image.DrawText('Earth years: '+ ToStr(year), [50,50], $FFFFFF);
- end;
- Self.Pos.Distance := Self.Distance ** 0.27;
- Self.Pos.Angle := Modulo(Self.Pos.Angle + speed/Self.Distance*speedscale, 2*PI);
- Result.x := Round(Middle.x + Self.Pos.Distance * Cos(Self.Pos.Angle));
- Result.y := Round(Middle.y + Self.Pos.Distance * Sin(Self.Pos.Angle));
- if Self.pathrad = 0 then Self.pathrad := Ceil(Result.DistanceTo(Middle));
- image.DrawCircleAA(middle, Self.pathrad, $222222, 1);
- image.DrawCircleAA(Result, size, Self.Color, size);
- end;
- procedure Update(Image: TImage);
- begin
- Mercury.Tick(image); Venus.Tick(image); Earth.Tick(image); Mars.Tick(image);
- Jupiter.Tick(image); Saturn.Tick(image); Uranus.Tick(image); Neptune.Tick(image);
- end;
- var
- tmp: TImage;
- begin
- Sun.Diameter := 696340*2;
- Sun.Mass := 2*10**30;
- Sun.Distance := 0;
- Mercury.Diameter := 2440*2;
- Mercury.Mass := 3.3010*10**23;
- Mercury.Distance := 57.9*10**6;
- Mercury.Color := Colors.SLATEGREY;
- Venus.Diameter := 6052*2;
- Venus.Mass := 4.1380*10**24;
- Venus.Distance := 108.2*10**6;
- Venus.Color := Colors.PALE_VIOLETRED;
- Earth.Diameter := 6371*2;
- Earth.Mass := 5.97*10**24;
- Earth.Distance := 149.6*10**6;
- Earth.Color := Colors.SKYBLUE;
- Mars.Diameter := 3390*2;
- Mars.Mass := 6.4273*10**23;
- Mars.Distance := 228.0*10**6;
- Mars.Color := Colors.RED;
- Jupiter.Diameter := 69911*2;
- Jupiter.Mass := 1.89852*10**27;
- Jupiter.Distance := 778.5*10**6;
- Jupiter.Color := Colors.MEDIUM_BLUE;
- Saturn.Diameter := 58232*2;
- Saturn.Mass := 5.6846*10**26;
- Saturn.Distance := 1432.0*10**6;
- Saturn.Color := Colors.BEIGE;
- Uranus.Diameter := 25362*2;
- Uranus.Mass := 8.6819*10**25;
- Uranus.Distance := 2867.0*10**6;
- Uranus.Color := Colors.SKYBLUE;
- Neptune.Diameter := 24622*2;
- Neptune.Mass := 1.02431*10**26;
- Neptune.Distance := 4515.0*10**6;
- Neptune.Color := Colors.DARK_BLUE;
- image := TImage.Create(1000,1000);
- while True do
- begin
- image.DrawCircleAA(Middle, Sun.SizeScaled(), $88FFFF, Sun.SizeScaled());
- Update(image);
- //tmp := image.ResizeBilinear(image.GetWidth() div 4, image.GetHeight() div 4);
- image.Show(False);
- //tmp.Free();
- image.Clear();
- //TerminateScript;
- end;
- image.Free();
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement