|
unit grafpac;
interface
uses graph;
type
casi = (Vuoto,Muro,Cibo,Pac,Gosth);
direzione= (N,S,E,O,Stop);
var grafica,modo:integer;
i,j:integer;
col:word;
coor,x,y:integer;
ain,afin:word;
cx1,cy1,cx2,cy2:integer;
CONST
MX=33;MY=24;Q=20; C=10;
procedure inizio;
procedure griglia;
procedure disegna(coor,x,y,dir:integer);
procedure disfant(coor,x,y:integer);
implementation
procedure griglia;
begin
setcolor(red);
for i:= 1 to MX-6 do
line(i*Q,0,i*Q,476);
for i:= 1 to MY do
line(0,i*Q,647-140,i*Q);
end;
procedure inizio;
begin
griglia;
end;
procedure disegna(coor,x,y,dir:integer);
begin
case coor of
1: col:=red;
2: col:=Yellow;
3: col:=black;
4: col:=green;
end;
If (coor=4) then
begin {stampo il cibo}
setcolor(black);
setfillstyle(1,black);
bar(x*Q-18,y*Q-18,x*Q-1,y*Q-1);
floodfill(x*Q-8,y*Q-8,black);
setcolor(col);
setfillstyle(1,col);
circle(x*Q-10,y*Q-10,1);
floodfill(x*Q-C,y*20-C,col);
end
else
if coor=2 then
begin {stampo il pac}
case dir of
1:begin ain:=120;afin:=50;cx1:=-4;cy1:=-5;cx2:=4;cy2:=-5;end;
2:begin ain:=310;afin:=230;cx1:=-4;cy1:=5;cx2:=4;cy2:=5;end;
3:begin ain:=50;afin:=320;cx1:=4;cy1:=-5;cx2:=4;cy2:=5;end;
4:begin ain:=220;afin:=140;cx1:=-5;cy1:=-4;cx2:=-5;cy2:=4;end;
end;
setcolor(col);
setfillstyle(1,col);
arc(x*Q-C,y*Q-C,ain,afin,8);
line(x*q-c,y*Q-C,x*Q-C+cx1,y*Q-C+cy1);
line(x*q-c,y*Q-C,x*Q-C+cx2,y*Q-C+cy2);
floodfill(x*Q-C-cx1,y*Q-C-cy1,col);
end
else
if (coor=3) or (coor=1) then
begin
setcolor(col);
setfillstyle(1,col);
bar(x*Q-18,y*Q-18,x*Q-1,y*Q-1);
floodfill(x*Q-8,y*Q-8,col);
end;
end;
procedure disfant(coor,x,y:integer);
begin
setcolor(coor);
arc(x*Q-C,y*Q-C-2,0,180,5);
line(x*Q-C-5,Y*Q-C-2,X*Q-C-5,Y*Q-C+8);
line(x*Q-C+5,Y*Q-C-2,X*Q-C+5,Y*Q-C+8);
{zigzag}
line(x*Q-C-5,y*Q-C+8,X*Q-C-3,y*Q-C+5);
line(x*Q-C-3,y*Q-C+5,x*Q-C,y*Q-C+8);
line(x*Q-C,y*Q-C+8,x*Q-C+3,y*Q-C+5);
line(x*Q-C+3,y*Q-C+5,x*Q-C+5,y*Q-C+8);
setfillstyle(1,coor);
floodfill(x*Q-C,y*Q-C,coor);
setcolor(black);
circle(x*Q-C-2,y*Q-C-2,1);
circle(x*Q-C+2,y*Q-C-2,1);
setfillstyle(1,black);
floodfill(x*Q-C-2,y*Q-C-2,black);
floodfill(x*Q-C+2,y*Q-C-2,black);
end;
end.
|
|