Anda di halaman 1dari 3

Dosen : Rio Anshari, M.

Si
Matakuliah : Algoritma dan Pemograman

Dasar Animasi dan Simulasi

Tugas awal sebelum kuliah

Pelajarilah/caritahulah terlebih dahulu konsep berikut sebelum perkuliahan dimulai :


1. Bagaimana membuka dan menutup mode grafik pada Turbo Pascal ?
2. Bagaimanakah konsep membuat objek bergerak pada mode grafik Turbo Pascal ?
3. Apakah itu koordinat alam semesta dan untuk apakah gunanya ?

program peluru_animasi;
uses crt, graph;
var
Vo,theta1, theta2, theta3,t,x1,x2,x3,y1,y2,y3,g : real;
gd, gm : integer;
Voi,theta1i,theta2i,theta3i : string;

begin

gd:=Vga;
gm:=VgaHi;
initgraph (gd,gm,'c:\tp\bgi');
setbkcolor(yellow);
setcolor(blue);
settextstyle(1,0,2);
settextjustify(0,0);

outtextxy(getmaxx div 2-80,100,'GERAK PELURU');


outtextxy(30,200,'masukkan nilai berikut');
outtextxy(30,250,'Kecepatan Awal (Vo) : ');
readln(Vo);
str(Vo:8:2,Voi);
outtextxy(300,250,Voi);

outtextxy(30,280,'Sudut Elevasi 1 (Theta1) : ');


readln(theta1);
str(theta1:8:2,theta1i);
outtextxy(300,280,theta1i);
outtextxy(30,310,'Sudut Elevasi 2 (Theta2) : ');
readln(theta2);
str(theta2:8:2,theta2i);
outtextxy(300,310,theta2i);

outtextxy(30,340,'Sudut Elevasi 3 (Theta3) : ');


readln(theta3);
str(theta3:8:2,theta3i);
outtextxy(300,340,theta3i);

readln;

theta1:=(theta1*pi)/180;
theta2:=(theta2*pi)/180;
theta3:=(theta3*pi)/180;
g:=10;

t:=0;

cleardevice;
setbkcolor (green);
line (10,4*getmaxy div 5 , getmaxx-10, 4*getmaxy div 5);
line (10,4*getmaxy div 5+2, getmaxx-10, 4*getmaxy div 5+2);
line (10,4*getmaxy div 5+4, getmaxx-10, 4*getmaxy div 5+4);
line (10,4*getmaxy div 5+6, getmaxx-10, 4*getmaxy div 5+6);

repeat

x1:=Vo*cos(theta1)*t;
x2:=Vo*cos(theta2)*t;
x3:=Vo*cos(theta3)*t;

y1:=(Vo*sin(theta1)*t)-((g*t*t)/2);
y1:=4*getmaxy div 5-round(y1);

y2:=(Vo*sin(theta2)*t)-((g*t*t)/2);
y2:=4*getmaxy div 5-round(y2);

y3:=(Vo*sin(theta3)*t)-((g*t*t)/2);
y3:=4*getmaxy div 5-round(y3);

if y1>4*getmaxy div 5 then


begin
y1:=4*getmaxy div 5+20;
x1:=getmaxx;
end;
if y2>4*getmaxy div 5 then
begin
y2:=4*getmaxy div 5+20;
x2:=getmaxx;
end;

if y3>4*getmaxy div 5 then


begin
y3:=4*getmaxy div 5+20;
x3:=getmaxx;
end;

setcolor (blue);
circle (round(x1)+50,round(y1),5);

setcolor (red);
circle (round(x2)+50,round(y2),5);

setcolor (yellow);
circle (round(x3)+50,round(y3),5);

delay(500);
t:=t+0.05;

until (y1>4*getmaxy div 5) and (y2>4*getmaxy div 5) and (y3>4*getmaxy div 5);

outtextxy(50,50,'lintasan biru : '); outtextxy(250,50,theta1i);


outtextxy(50,70,'lintasan merah : '); outtextxy(250,70,theta2i);
outtextxy(50,90,'lintasan kuning : '); outtextxy(250,90,theta3i);

repeat until keypressed;


closegraph;
end.