Minggu, 03 Mei 2009

membuat garis acak di turbo pascal

Sebelum ke program ini directory pndahkan k work dan di folder pascal
yang bernama bin..,., copy file .chr dan avga dan supervga dan di folder unit file grafh.tpu di copy dan semuanya di pindahkan ke folder work...oke



Program Garis_Acak;
uses
Graph, crt;
var
gd, gm, xmax, ymax,
x1, x2, y1, y2 : integer;
DriverGrafis,
ModeGrafis : Integer;
begin
Clrscr;
DriverGrafis := detect;
InitGraph (DriverGrafis, ModeGrafis, '');
if GraphResult <> grOK Then
Halt(1); {berhenti}

xmax := GetMaxX;
ymax := GetMaxX;
Rectangle(0,0,xmax,ymax);

Randomize;

repeat
x1 := Random (xmax);
x2 := Random (ymax);
y1 := Random ((xmax - x1) + x1);
y2 := Random ((ymax - y1) + y1);

Line(x1,y1,x2,y2);

Until keypressed;
CloseGraph;
end.

0 komentar: