Planet solar system adalah sebuah program animasi kecil - kecilan yang semua planet berputar mengililing tata surya dan bulan mengililing bumi.
untuk lebih jelasnya langsung saja kita ke TKP.
buka delphi anda dan tambahkan 10 komponen Shape , 10 komponen image, 2 komponen button dan 1 komponen
aturlah seperti pada gambar dibawah ini
kemudian ketikkan listing di komponen timer dibawah ini:
procedure TForm1.Timer1Timer(Sender: TObject);
var x9,y9,x8,y8,x7,y7,x6,y6,x5,y5,x4,y4,x3,y3,x2,y2,x1,y1,a1,b1,c1,d1: 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:=((orbituranus.Width)/2)+(orbituranus.Left)+((orbituranus.width)/2)*cos(-6*theta);
y8:=((orbituranus.height/2)+(orbituranus.top))-(orbituranus.height/2)*sin(-6*theta);
x7:=((orbitneptunus.Width)/2)+(orbitneptunus.Left)+((orbitneptunus.width)/2)*cos(2*theta);
y7:=((orbitneptunus.height/2)+(orbitneptunus.top))-(orbitneptunus.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:=((orbityupiter.Width)/2)+(orbityupiter.Left)+((orbityupiter.width)/2)*cos(5*theta);
y5:=((orbityupiter.height/2)+(orbityupiter.top))-(orbityupiter.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);
a1:=((orbitbulan.Width)/2)+(orbitbulan.Left)+((orbitbulan.width)/2)*cos(-10*theta);
b1:=((orbitbulan.height/2)+(orbitbulan.top))-(orbitbulan.height/2)*sin(-10*theta);
pluto.Left:=trunc(x9) -constanta;
pluto.Top:=trunc(y9) -constanta;
uranus.Left:=trunc(x8) -constanta;
uranus.Top:=trunc(y8) -constanta;
neptunus.Left:=trunc(x7) -constanta;
neptunus.Top:=trunc(y7) -constanta;
saturnus.Left:=trunc(x6) -constanta;
saturnus.Top:=trunc(y6) -constanta;
yupiter.Left:=trunc(x5) -constanta;
yupiter.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;
orbitbulan.Left:=trunc(x3) -constan;
orbitbulan.Top :=trunc(y3) -constan;
bln.Left :=trunc(a1) -constanta;
bln.Top:=trunc(b1) -constanta;
theta:=theta+c;
if (theta>=2*d) then theta:=0.0;
end;
var x9,y9,x8,y8,x7,y7,x6,y6,x5,y5,x4,y4,x3,y3,x2,y2,x1,y1,a1,b1,c1,d1: 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:=((orbituranus.Width)/2)+(orbituranus.Left)+((orbituranus.width)/2)*cos(-6*theta);
y8:=((orbituranus.height/2)+(orbituranus.top))-(orbituranus.height/2)*sin(-6*theta);
x7:=((orbitneptunus.Width)/2)+(orbitneptunus.Left)+((orbitneptunus.width)/2)*cos(2*theta);
y7:=((orbitneptunus.height/2)+(orbitneptunus.top))-(orbitneptunus.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:=((orbityupiter.Width)/2)+(orbityupiter.Left)+((orbityupiter.width)/2)*cos(5*theta);
y5:=((orbityupiter.height/2)+(orbityupiter.top))-(orbityupiter.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);
a1:=((orbitbulan.Width)/2)+(orbitbulan.Left)+((orbitbulan.width)/2)*cos(-10*theta);
b1:=((orbitbulan.height/2)+(orbitbulan.top))-(orbitbulan.height/2)*sin(-10*theta);
pluto.Left:=trunc(x9) -constanta;
pluto.Top:=trunc(y9) -constanta;
uranus.Left:=trunc(x8) -constanta;
uranus.Top:=trunc(y8) -constanta;
neptunus.Left:=trunc(x7) -constanta;
neptunus.Top:=trunc(y7) -constanta;
saturnus.Left:=trunc(x6) -constanta;
saturnus.Top:=trunc(y6) -constanta;
yupiter.Left:=trunc(x5) -constanta;
yupiter.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;
orbitbulan.Left:=trunc(x3) -constan;
orbitbulan.Top :=trunc(y3) -constan;
bln.Left :=trunc(a1) -constanta;
bln.Top:=trunc(b1) -constanta;
theta:=theta+c;
if (theta>=2*d) then theta:=0.0;
end;
pada button mulai ketikan listing dibawah ini:
procedure TForm1.Button1Click(Sender: TObject);
begin
timer1.Enabled:=true;
constan :=26;
constanta:=5;
theta:=0.0;
c:=1/100;
d:=2*PI;
end;
begin
timer1.Enabled:=true;
constan :=26;
constanta:=5;
theta:=0.0;
c:=1/100;
d:=2*PI;
end;
pada button stop berikan listing seperti dibawah ini :
procedure TForm1.Button2Click(Sender: TObject);
begin
timer1.Enabled:=false;
end;
begin
timer1.Enabled:=false;
end;
pada bagian atas (kenalkan variable dibawah ini pada bagian variable GLOBAL
var
Form1: TForm1;
theta,d,c:real;
constanta,f,constan:integer;
Form1: TForm1;
theta,d,c:real;
constanta,f,constan:integer;
sehingga hasil program kecilnya seperti pada gambar dibawah ini:
untuk lebih lengkapnya sobat bisa download langsung disini
tqz sob... :P
BalasHapussangat bermanfaat untuk hari ini.. :D
link downloadnya di upload ulang dong, gabisa di download tuh
BalasHapusmin, itu gambar planet sama buminya itu foto?
BalasHapus