Pac-Man versione 1.0 - GRAFPAC.PAS
Cerca
 











GRAFPAC.PAS

Caricato da: Alex
Scarica il programma completo

  1. unit grafpac;
  2. interface
  3. uses graph;
  4. type
  5.  casi = (Vuoto,Muro,Cibo,Pac,Gosth);
  6.  direzione= (N,S,E,O,Stop);
  7. var grafica,modo:integer;
  8.   i,j:integer;
  9.   col:word;
  10.   coor,x,y:integer;
  11.   ain,afin:word;
  12.   cx1,cy1,cx2,cy2:integer;
  13. CONST
  14.  MX=33;MY=24;Q=20; C=10;
  15. procedure inizio;
  16. procedure griglia;
  17. procedure disegna(coor,x,y,dir:integer);
  18. procedure disfant(coor,x,y:integer);
  19.  
  20.  
  21. implementation
  22.  
  23. procedure griglia;
  24. begin
  25.  setcolor(red);
  26. for i:= 1 to MX-6 do
  27.  line(i*Q,0,i*Q,476);
  28. for i:= 1 to MY do
  29.  line(0,i*Q,647-140,i*Q);
  30. end;
  31. procedure inizio;
  32. begin
  33.  
  34.   griglia;
  35.  
  36.  
  37.  end;
  38. procedure disegna(coor,x,y,dir:integer);
  39.  
  40. begin
  41.  case coor of
  42.      1: col:=red;
  43.      2: col:=Yellow;
  44.      3: col:=black;
  45.      4: col:=green;
  46.     end;
  47.  If (coor=4) then
  48.   begin             {stampo il cibo}
  49.    setcolor(black);
  50.    setfillstyle(1,black);
  51.    bar(x*Q-18,y*Q-18,x*Q-1,y*Q-1);
  52.    floodfill(x*Q-8,y*Q-8,black);
  53.    setcolor(col);
  54.    setfillstyle(1,col);
  55.    circle(x*Q-10,y*Q-10,1);
  56.    floodfill(x*Q-C,y*20-C,col);
  57.   end
  58.  else
  59.   if coor=2 then
  60.    begin     {stampo il pac}
  61.     case dir of
  62.     1:begin ain:=120;afin:=50;cx1:=-4;cy1:=-5;cx2:=4;cy2:=-5;end;
  63.     2:begin ain:=310;afin:=230;cx1:=-4;cy1:=5;cx2:=4;cy2:=5;end;
  64.     3:begin ain:=50;afin:=320;cx1:=4;cy1:=-5;cx2:=4;cy2:=5;end;
  65.     4:begin ain:=220;afin:=140;cx1:=-5;cy1:=-4;cx2:=-5;cy2:=4;end;
  66.     end;
  67.  
  68.     setcolor(col);
  69.     setfillstyle(1,col);
  70.     arc(x*Q-C,y*Q-C,ain,afin,8);
  71.     line(x*q-c,y*Q-C,x*Q-C+cx1,y*Q-C+cy1);
  72.     line(x*q-c,y*Q-C,x*Q-C+cx2,y*Q-C+cy2);
  73.     floodfill(x*Q-C-cx1,y*Q-C-cy1,col);
  74.   end
  75.   else
  76.   if (coor=3) or (coor=1) then
  77.   begin
  78.   setcolor(col);
  79.    setfillstyle(1,col);
  80.    bar(x*Q-18,y*Q-18,x*Q-1,y*Q-1);
  81.    floodfill(x*Q-8,y*Q-8,col);
  82.   end;
  83.  end;
  84. procedure disfant(coor,x,y:integer);
  85.  
  86.  begin
  87.   setcolor(coor);
  88.   arc(x*Q-C,y*Q-C-2,0,180,5);
  89.   line(x*Q-C-5,Y*Q-C-2,X*Q-C-5,Y*Q-C+8);
  90.   line(x*Q-C+5,Y*Q-C-2,X*Q-C+5,Y*Q-C+8);
  91.   {zigzag}
  92.   line(x*Q-C-5,y*Q-C+8,X*Q-C-3,y*Q-C+5);
  93.   line(x*Q-C-3,y*Q-C+5,x*Q-C,y*Q-C+8);
  94.   line(x*Q-C,y*Q-C+8,x*Q-C+3,y*Q-C+5);
  95.   line(x*Q-C+3,y*Q-C+5,x*Q-C+5,y*Q-C+8);
  96.   setfillstyle(1,coor);
  97.   floodfill(x*Q-C,y*Q-C,coor);
  98.   setcolor(black);
  99.   circle(x*Q-C-2,y*Q-C-2,1);
  100.   circle(x*Q-C+2,y*Q-C-2,1);
  101.   setfillstyle(1,black);
  102.   floodfill(x*Q-C-2,y*Q-C-2,black);
  103.   floodfill(x*Q-C+2,y*Q-C-2,black);
  104.  end;
  105.  
  106. end.
 

Creative Commons License
Il layout di questo sito è concesso sotto licenza Creative Commons.
Per maggiori informazioni sulle licenze dei contenuti del sito, clicca.