RSS

Solar System with Delphi

To make a project like that, the first step is choose the timer on the system and select 2 button and then click the name of the caption andthen replace with start and stop.
do not forget to add the image to your Delphi form.
Andthen, fill the project with the program of  solar system.
you can see the syntax of project like that....



unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, jpeg;


type
  TForm1 = class(TForm)
    Image1: TImage;
    sun: TImage;
    merkurius: TImage;
    venus: TImage;
    bumi: TImage;
    mars: TImage;
    jupiter: TImage;
    saturnus: TImage;
    uranus: TImage;
    neptunus: TImage;
    pluto: TImage;
    moon: TImage;
    Orbitmerkurius: TShape;
    orbitvenus: TShape;
    orbitbumi: TShape;
    orbitmars: TShape;
    orbitjupiter: TShape;
    orbitsaturnus: TShape;
    orbituranus: TShape;
    orbitneptunus: TShape;
    orbitpluto: TShape;
    orbitmoon: TShape;
    Timer1: TTimer;
    Button1: TButton;
    Button2: TButton;
    Label1: TLabel;
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
    theta,d,c:real;
  constanta,constan:integer;


implementation

{$R *.dfm}

procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
timer1.Enabled:=true;
  constan :=26;
  constanta:=5;
  theta:=0.0;
  c:=1/100;
  d:=2*PI;
end;



procedure TForm1.Timer1Timer(Sender: TObject);
var x9,y9,x8,y8,x7,y7,x6,y6,x5,y5,x4,y4,x3,y3,x2,y2,x1,y1,r,p: real;
begin
if (theta<=(2*d)) then
x9:=((orbitPluto.Width)/2)+(orbitPluto.Left)+((orbitPluto.width)/2)*cos(-3*theta);
y9:=((orbitPluto.height/2)+(orbitPluto.top))-(orbitPluto.height/2)*sin(-3*theta);
x8:=((orbitNeptunus.Width)/2)+(orbitNeptunus.Left)+((orbitNeptunus.width)/2)*cos(-6*theta);
y8:=((orbitNeptunus.height/2)+(orbitNeptunus.top))-(orbitNeptunus.height/2)*sin(-6*theta);
x7:=((orbitUranus.Width)/2)+(orbitUranus.Left)+((orbitUranus.width)/2)*cos(2*theta);
y7:=((orbitUranus.height/2)+(orbitUranus.top))-(orbitUranus.height/2)*sin(2*theta);
x6:=((orbitSaturnus.Width)/2)+(orbitSaturnus.Left)+((orbitSaturnus.width)/2)*cos(4*theta);
y6:=((orbitSaturnus.height/2)+(orbitSaturnus.top))-(orbitSaturnus.height/2)*sin(4*theta);
x5:=((orbitJupiter.Width)/2)+(orbitJupiter.Left)+((orbitJupiter.width)/2)*cos(5*theta);
y5:=((orbitJupiter.height/2)+(orbitJupiter.top))-(orbitJupiter.height/2)*sin(5*theta);
 x4:=((orbitMars.Width)/2)+(orbitMars.Left)+((orbitMars.width)/2)*cos(3*theta);
 y4:=((orbitMars.height/2)+(orbitMars.top))-(orbitMars.height/2)*sin(3*theta);
 x3:=((orbitBumi.Width)/2)+(orbitBumi.Left)+((orbitBumi.width)/2)*cos(-theta);
 y3:=((orbitBumi.height/2)+(orbitBumi.top))-(orbitBumi.height/2)*sin(-theta);
 x2:=((orbitVenus.Width)/2)+(orbitVenus.Left)+((orbitVenus.width)/2)*cos(-4*theta);
  y2:=((orbitVenus.height/2)+(orbitVenus.top))-(orbitVenus.height/2)*sin(-4*theta);
  x1:=((orbitMerkurius.Width)/2)+(orbitMerkurius.Left)+((orbitMerkurius.width)/2)*cos(6*theta);
  y1:=((orbitMerkurius.height/2)+(orbitMerkurius.top))-(orbitMerkurius.height/2)*sin(6*theta);
       r:=((orbitMoon.Width)/2)+(orbitMoon.Left)+((orbitMoon.width)/2)*cos(-10*theta);
         p:=((orbitMoon.height/2)+(orbitMoon.top))-(orbitMoon.height/2)*sin(-10*theta);

    Pluto.Left:=trunc(x9) -constanta;
    Pluto.Top:=trunc(y9) -constanta;
    Neptunus.Left:=trunc(x8) -constanta;
    Neptunus.Top:=trunc(y8) -constanta;
    Uranus.Left:=trunc(x7) -constanta;
    Uranus.Top:=trunc(y7) -constanta;
    Saturnus.Left:=trunc(x6) -constanta;
    Saturnus.Top:=trunc(y6) -constanta;
    Jupiter.Left:=trunc(x5) -constanta;
    Jupiter.Top:=trunc(y5) -constanta;
    Mars.Left:=trunc(x4) -constanta;
    Mars.Top:=trunc(y4) -constanta;
    Bumi.Left:=trunc(x3) -constanta;
    Bumi.Top:=trunc(y3) -constanta;
    Venus.Left:=trunc(x2) -constanta;
    Venus.Top:=trunc(y2) -constanta;
    Merkurius.Left:=trunc(x1) -constanta;
    Merkurius.Top:=trunc(y1) -constanta;
    orbitMoon.Left:=trunc(x3) -constan;
    orbitMoon.Top :=trunc(y3) -constan;
    Moon.Left :=trunc(r)-constanta;
    Moon.Top:=trunc(p)-constanta;
    theta:=theta+c;
    if (theta>=2*d) then theta:=0.0;
end;

end.

0 komentar:

Posting Komentar