Minggu, 13 April 2014

Animasi Pada Delphi (Pascal Language)

Dapet tugas epic dari praktek, pake delphi7 bahasa pemrogramannya pascal, kurang lebih kodingannya kaya gini nih:
---------------------------------------------------------------------------------------
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if a=0 then
begin
button1.caption:='x';
button1.Left:=button1.Left+1;
if button1.Left=388 then
a:=388;
end;
if a=388 then
begin
button1.Caption:='x';
button1.Left:=button1.left-1;
if button1.Left=0 then
a:=0;
end;
if b=0 then
begin
button2.Caption:='x';
button2.Top:=button2.top+1;
if button2.Top=388 then
b:=388;
end;
if b=388 then
begin
button2.Caption:='x';
button2.Top:=button2.top-1;
if button2.Top=0 then
b:=0;
end;
if c=388 then
begin
button3.Caption:='x';
button3.Left:=button3.left-1;
if button3.Left=0 then
c:=0;
end;
if c=0 then
begin
button3.Caption:='x';
button3.Left:=button3.left+1;
if button3.Left=388 then
c:=388;
end;
if d=388 then
begin
button4.Caption:='x';
button4.Top:=button4.top-1;
if button4.Top=0 then
d:=0;
end;
if d=0 then
begin
button4.Caption:='x';
button4.Top:=button4.top+1;
if button4.Top=388 then
d:=388;
end;

end;

procedure TForm1.FormCreate(Sender: TObject);
begin
a:=0;
b:=0;
c:=388;
d:=388;
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
Timer1.enabled:=True;
end;

procedure TForm1.Button6Click(Sender: TObject);
begin
Timer1.enabled:=False;
end;
----------------------------------------------------------------------------------

note: jangan lupa variabelnya di perhatiin trus tipe data variabelnya itu "Integer" taro di blok var yang di atas :)


yap! emang pusing tapi kalo ngerti logikanya pasti gampang malah bisa buat yang lebih ribet, lol.

logikanya? coba aja di copas ke delphi7nya trus inspect sendiri objek apa aja yang mesti di taro di formnya "biar pinter" kalo kata dosen gue ;)

output kaya gini nih:







Good luck adn CHEERS XD
 

Tidak ada komentar:

Posting Komentar