unit obrazce;
interface
uses graph,crt,dos;
const xm=505;
type bod=object
x,y,sx,sy,krok,druh:integer;
constructor init(xi,yi,sxi,syi:integer);
function ukazX:integer;
function ukazY:integer;
function ukazSX:integer;
function ukazSY:integer;
function ukazKrok:integer;
function cojsem:integer;
procedure svit(b:byte);virtual;
procedure pohyb(p:char);
end;
ubod=^bod;
cara=object(bod)
procedure svit(b:byte);virtual;
end;
elipsa=object(bod)
procedure svit(b:byte);virtual;
end;
obdelnik=object(bod)
procedure svit(b:byte);virtual;
end;
procedure inigra;procedure clogra;
procedure menu;procedure menub;procedure menuo;procedure help;
procedure vymaz;procedure vymaz2;procedure escejp;
{*********************************************}
{*********************************************}
{*********************************************}
implementation
{ O B J E K T Y }
{bod}
constructor bod.init(xi,yi,sxi,syi:integer);
begin x:=xi; y:=yi; sx:=sxi; sy:=syi; krok:=1; end;
function bod.ukazX:integer;
begin ukazX:=X; end;
function bod.ukazY:integer;
begin ukazY:=Y; end;
function bod.ukazSX:integer;
begin ukazSX:=SX; end;
function bod.ukazSY:integer;
begin ukazSY:=SY; end;
function bod.ukazKrok:integer;
begin ukazkrok:=krok; end;
function bod.cojsem:integer;
begin cojsem:=druh; end;
procedure bod.svit(b:byte);
begin putpixel(x,y,b); druh:=1; end;
procedure bod.pohyb(p:char);
begin
case ord(p) of
72: y:=y-krok;{dolu}
80: y:=y+krok;{nahoru}
75: x:=x-krok;{doleva}
77: x:=x+krok;{doprava}
50: sy:=sy+krok;{vyska zvetsi}
52: sx:=sx-krok;{sirka zmensi}
54: sx:=sx+krok;{sirka zvetsi}
56: sy:=sy-krok;{vyska zmensi}
43: begin krok:=krok+1; if krok=21 then krok:=20; end;
45: begin krok:=krok-1; if krok=0 then krok:=1; end;
end;
end;
{cara}
procedure cara.svit(b:byte);
begin setcolor(b); line(x,y,x+sx,y+sy); druh:=2; end;
{kruznice}
procedure elipsa.svit(b:byte);
begin setcolor(b); ellipse(round(x+(sx/2)),round(y+(sy/2)),0,360,round(sx/2),round(sy/2)); druh:=3; end;
{obdelnik}
procedure obdelnik.svit(b:byte);
begin setcolor(b); rectangle(x,y,x+sx,y+sy); druh:=4; end;
{ I N I C I A L I Z A C E G R A F I K Y }
procedure IniGra;
var GraphDriver, GraphMode: Integer;
begin
DetectGraph(GraphDriver, GraphMode);
if (GraphDriver = EGA) or
(GraphDriver = EGA64) then
begin
GraphDriver := CGA;
GraphMode := CGAHi;
end;
InitGraph(GraphDriver, GraphMode,'');
if GraphResult <> grOk then
Halt(1);
end;
procedure CloGra; begin CloseGraph; end;
{ M A Z A N I O B R A Z O V K Y }
procedure vymaz;
begin cleardevice; end;
procedure vymaz2;
var c:word;
begin
setfillstyle(0,0);
bar(getmaxx-140,0,getmaxx,getmaxy);
end;
{ M E N U }
procedure menu;
begin
setcolor(15);
rectangle(0,0,getmaxx-140,getmaxy);
rectangle(getmaxx-140,0,getmaxx,getmaxy);
outtextxy(xm,10,'OVLADANI');
outtextxy(xm,15,'________________');
outtextxy(xm,30,'F1 - Bod');
outtextxy(xm,40,'F2 - Cara');
outtextxy(xm,50,'F3 - Elipsa');
outtextxy(xm,60,'F4 - Obdelnik');
outtextxy(xm,65,'________________');
outtextxy(xm,80,'Tab - Zmen');
outtextxy(xm,90,'F5 - Kopiruj');
outtextxy(xm,100,'Del - Smaz');
outtextxy(xm,110,'F6 - Smaz vse');
outtextxy(xm,115,'________________');
outtextxy(xm,130,'F7 - Otevri');
outtextxy(xm,140,'F8 - Uloz');
outtextxy(xm,150,'F9 - Nahled');
outtextxy(xm,160,'F10 - Napoveda');
outtextxy(xm,165,'________________');
outtextxy(xm,180,'End - Konec');
outtextxy(xm,185,'________________');
end;
procedure menub;
begin
setcolor(11);
outtextxy(xm,300,'pohyb sipkami');
outtextxy(xm,310,'rychleji +');
outtextxy(xm,320,'pomaleji -');
end;
procedure menuo;
begin
menub;
outtextxy(xm,340,'sirka: (num. kl.)');
outtextxy(xm,350,'2 - dolu');
outtextxy(xm,360,'6 - doprava');
outtextxy(xm,370,'8 - nahoru');
outtextxy(xm,380,'4 - doleva');
end;
procedure escejp;
var kla:char;
begin
outtextxy(610,470,'Esc');
repeat
kla:=readkey; if ord(kla)=0 then kla:=readkey;
until ord(kla)=27;
vymaz;
end;
procedure help;
begin
vymaz;
outtextxy(100,100,'Vyrobeno jako zapoctovy progrmam na predmet PGM3');
outtextxy(100,120,' Jan Pejsa');
escejp;
end;
{ M A I N }
begin;
{inicializace unity pri prvnim volani}
writeln('K R E S L E N I');
writeln('(c) 2000, Jan Pejsa');
writeln;
writeln('vytvoreno jako zapoctovy program na predmet PGM3');
delay(500);
end.
Zpět