offline
- LaserJat
- Super građanin
- Pridružio: 26 Jul 2004
- Poruke: 1472
- Gde živiš: Vojvodina,Zrenjanin
|
Jel moze ovako nesto kao pacman
komande su 4-levo 6-desno 2-dole 8-gore.
program pacman;
uses crt, graph;
type point=^element;
element=record
im: pointer;
nxt: point;
end;
fx=^coord;
coord=record
fa, fo, rf, delais: integer;
nxt: fx;
end;
tableau=array[1..3]of integer;
procedure infos;
var i,j,k: integer;
begin
for i:=1 to 2 do begin
if i=1 then
setcolor(3)
else setcolor(0);
outtextxy(180,15,'Adaptation of the game:');
outtextxy(60,452,'Left: 4');
outtextxy(60,472,'Right: 6');
outtextxy(190,452,'Up: 8');
outtextxy(190,472,'Down: 2');
outtextxy(320,452,'Stop!: 5');
outtextxy(320,472,'Pause: P');
outtextxy(450,452,'Sound/Sil.:S');
outtextxy(450,472,'Iwannaquit:Q');
if i=1 then begin
repeat
for j:=1 to 20 do begin
for k:=1 to 2 do begin
if k=1 then setcolor(4) else setcolor(0);
outtextxy(380+1*j,15,'F');
outtextxy(390+2*j,15,'r');
outtextxy(400+3*j,15,'e');
outtextxy(410+4*j,15,'d');
if k=1 then delay(600);
end;
end;
for j:=20 downto 1 do begin
for k:=1 to 2 do begin
if k=1 then setcolor(4) else setcolor(0);
outtextxy(380+1*j,15,'F');
outtextxy(390+2*j,15,'r');
outtextxy(400+3*j,15,'e');
outtextxy(410+4*j,15,'d');
if k=1 then delay(600);
end;
end;
until keypressed;
end;
end;
end;
procedure route(var t: tableau;x,y,fa,fo: integer);
var coef: real;
begin
coef:=(x-fa)/(y-fo+0.1);
if ((coef)>=1)or((coef)<=-1) then begin
if fa>=x then t[1]:=4 else t[1]:=6;
if fo>y then begin t[2]:=8; t[3]:=2; end else begin t[2]:=2; t[3]:=8; end;
end else begin
if fo>=y then t[1]:=8 else t[1]:=2;
if fa>x then begin t[2]:=4; t[3]:=6; end else begin t[2]:=6; t[3]:=4; end;
end;
end;
label 1;
var a, b, c, d, i, j, k, r, rf, x, y, size, pilote, mode, vies, repas,
t1, t2, t3, t4, t5, t6, t7, t8, niveau: integer;
tar, perdu, son, f1, f2, f3, f4, bonus: boolean;
p, p2, p3, ec, ec2, ec3: point;
fantome, blank, fade, vdt, repos, fromage, barre: pointer;
t: tableau;
pf, pf2, pf3: fx;
temps, points: longint;
stock:Array[1..24] of integer;
s: string;
begin
randomize;
pilote:=detect;
InitGraph(pilote,mode,'c:\tp\bgi');
clearviewport;
size:=imagesize(7,7,33,7);
new(fade);
getmem(fade,size);
getimage(7,7,33,7,fade^);
size:=imagesize(7,7,33,33);
new(blank);
getmem(blank,size);
getimage(7,7,33,33,blank^);
for j:=1 to 2 do begin
if j=1 then setfillstyle(1,9) else setfillstyle(1,6);
for i:=1 to 4 do begin
cleardevice;
pieslice(20,20,5*i,360-5*i,10);
rectangle(19,14,20,15);
size:=imagesize(7,7,33,33);
if j=1 then begin
new(p2);
getmem(p2^.im,size);
getimage(7,7,33,33,p2^.im);
if i=1 then begin
p:=p2;
p3:=p;
end else begin
p3^.nxt:=p2;
p3:=p2;
end;
end else begin
new(ec2);
getmem(ec2^.im,size);
getimage(7,7,33,33,ec2^.im);
if i=1 then begin
ec:=ec2;
ec3:=ec;
end else begin
ec3^.nxt:=ec2;
ec3:=ec2;
end;
end;
end;
for i:=3 downto 2 do begin
cleardevice;
pieslice(20,20,5*i,360-5*i,10);
rectangle(19,14,20,15);
size:=imagesize(7,7,33,33);
if j=1 then begin
new(p2);
getmem(p2^.im,size);
getimage(7,7,33,33,p2^.im);
p3^.nxt:=p2;
p3:=p2;
end else begin
new(ec2);
getmem(ec2^.im,size);
getimage(7,7,33,33,ec2^.im);
ec3^.nxt:=ec2;
ec3:=ec2;
end;
end;
p2^.nxt:=p;
ec2^.nxt:=ec;
end;
cleardevice;
setcolor(4);
rectangle(20,20,100,21);
size:=imagesize(20,20,100,21);
new(barre);
getmem(barre,size);
getimage(20,20,100,21,barre^);
cleardevice;
setcolor(4);
line(20,10,30,30);
line(20,10,10,30);
line(10,30,30,30);
line(16,20,20,20);
line(20,20,18,25);
line(18,25,16,20);
line(20,20,24,20);
line(24,20,22,25);
line(22,25,20,20);
setfillstyle(1,4);
floodfill(20,15,4);
floodfill(20,27,4);
setcolor(0);
line(17,27,23,27);
size:=imagesize(7,7,33,33);
new(fantome);
getmem(fantome,size);
getimage(7,7,33,33,fantome^);
setfillstyle(1,10);
floodfill(20,28,0);
size:=imagesize(7,7,33,33);
new(vdt);
getmem(vdt,size);
getimage(7,7,33,33,vdt^);
setfillstyle(1,5);
floodfill(20,28,0);
size:=imagesize(7,7,33,33);
new(repos);
getmem(repos,size);
getimage(7,7,33,33,repos^);
cleardevice;
setcolor(14);
rectangle(9,9,10,10);
size:=imagesize(9,9,10,10);
new(fromage);
getmem(fromage,size);
getimage(9,9,10,10,fromage^);
{1e init}
niveau:=0;
points:=0;
vies:=3;
son:=true;
b:=400;
repeat
cleardevice;
for i:=1 to 19 do
for j:=1 to 13 do
putimage(i*28+36,j*28+45,fromage^,normalput);
setcolor(1);
{bordure}
rectangle(50,60,582,424);
rectangle(49,59,583,425);
{motifs}
rectangle(78,88,161,144);
rectangle(471,88,554,144);
rectangle(78,340,161,396);
rectangle(471,340,554,396);
rectangle(189,60,218,144);
rectangle(414,60,443,144);
rectangle(189,340,218,424);
rectangle(414,340,443,424);
rectangle(246,88,386,144);
rectangle(246,340,386,396);
rectangle(50,172,161,228);
rectangle(471,172,582,228);
rectangle(50,256,161,312);
rectangle(471,256,582,312);
rectangle(189,172,443,312);
rectangle(190,173,442,311);
{Anti-fromages}
setfillstyle(1,0);
floodfill(300,200,1);
{passage secret}
setcolor(0);
rectangle(582,229,583,255);
rectangle(49,229,50,255);
rectangle(304,172,330,173);
{Remplissage}
setfillstyle(1,1);
floodfill(80,90,1);
floodfill(80,350,1);
floodfill(500,350,1);
floodfill(500,90,1);
floodfill(200,90,1);
floodfill(420,90,1);
floodfill(200,400,1);
floodfill(420,400,1);
floodfill(250,100,1);
floodfill(250,350,1);
floodfill(100,200,1);
floodfill(500,200,1);
floodfill(100,300,1);
floodfill(500,300,1);
{camemberts}
setfillstyle(1,2);
setcolor(2);
circle(65,75,5);
floodfill(65,75,2);
circle(65,409,5);
floodfill(67,409,2);
circle(566,75,5);
floodfill(566,75,2);
circle(566,409,5);
floodfill(566,409,2);
setcolor(3);
outtextxy(50,40,'lifes:');
outtextxy(156,40,'points: Energy: Level:');
outtextxy(290,435,'Infos:I');
setcolor(0);
str(niveau,s);
outtextxy(540,40,s);
niveau:=niveau+1;
setcolor(3);
str(niveau,s);
outtextxy(540,40,s);
str(vies,s);
outtextxy(105,40,s);
f1:=true;
f2:=true;
f3:=true;
f4:=true;
repas:=0;
for j:=1 to 16 do
stock[j]:=0;
1:
p2:=p;
ec2:=ec;
temps:=0;
perdu:=false;
new(pf);
pf^.fa:=304;
pf^.fo:=174;
pf^.rf:=4;
pf^.delais:=0;
new(pf2);
pf2^.fa:=304;
pf2^.fo:=210;
pf2^.rf:=8;
pf2^.delais:=0;
pf^.nxt:=pf2;
new(pf3);
pf3^.fa:=304;
pf3^.fo:=240;
pf3^.rf:=8;
pf3^.delais:=0;
pf2^.nxt:=pf3;
pf2:=pf3;
new(pf3);
pf3^.fa:=304;
pf3^.fo:=275;
pf3^.rf:=8;
pf3^.delais:=0;
pf3^.nxt:=nil;
pf2^.nxt:=pf3;
x:=303;
y:=313;
r:=5;
i:=1;
b:=b-20;
c:=b+30;
bonus:=false;
repeat
i:=i+1;
{Pac-itin‚raire}
if keypressed then r:=ord(readkey)-ord('0');
if r=ord('s')-ord('0') then son:=(son=false);
if r=ord('p')-ord('0') then repeat until keypressed;
if r=ord('i')-ord('0') then infos;
if i mod 4000=0 then if temps=0 then p2:=p2^.nxt else ec2:=ec2^.nxt;
if i mod b=0 then begin
if r=6 then if (getpixel(x+27,y)<>1)and(getpixel(x+27,y+26)<>1) then d:=r;
if r=4 then if (getpixel(x-1,y)<>1)and(getpixel(x-1,y+26)<>1) then d:=r;
if r=2 then if (getpixel(x,y+27)<>1)and(getpixel(x+26,y+27)<>1)and((x<>304)or(y<>145)) then d:=r;
if r=8 then if (getpixel(x,y-1)<>1)and(getpixel(x+26,y-1)<>1) then d:=r;
if r=5 then d:=0;
if d=6 then if (getpixel(x+27,y)<>1)and(getpixel(x+27,y+26)<>1) then x:=x+1 else d:=0;
if d=4 then if (getpixel(x-1,y)<>1)and(getpixel(x-1,y+26)<>1) then x:=x-1 else d:=0;
if d=2 then if (getpixel(x,y+27)<>1)and(getpixel(x+26,y+27)<>1) then y:=y+1 else d:=0;
if d=8 then if (getpixel(x,y-1)<>1)and(getpixel(x+26,y-1)<>1) then y:=y-1 else d:=0;
if ((d=6)and((getpixel(x+27,y+12)=14)or(getpixel(x+27,y+14)=14))
or((d=4)and((getpixel(x-1,y+12)=14)) or(getpixel(x-1,y+14)=14))
or((d=2)and((getpixel(x+12,y+27)=14))or(getpixel(x+14,y+27)=14))
or((d=8)and(getpixel(x+12,y-1)=14)or(getpixel(x+14,y-1)=14))) then begin
setcolor(0);
str(points,s);
outtextxy(220,40,s);
points:=points+10;
if points mod 4000=0 then bonus:=true;
repas:=repas+1;
setcolor(3);
str(points,s);
outtextxy(220,40,s);
end;
if temps>0 then begin
putimage(x,y,ec2^.im,normalput);
temps:=temps-1;
putimage(360+trunc(80*temps/(60*(10-niveau div 2))),20,blank^,normalput);
end else
putimage(x,y,p2^.im,normalput);
if (x=51)and(y=61)and(f1=true) then begin
f1:=false;
temps:=60*(10-niveau div 2);
putimage(360,43,barre^,normalput);
end;
if (x=555)and(y=61)and(f2=true) then begin
f2:=false;
temps:=60*(10-niveau div 2);
putimage(360,43,barre^,normalput);
end;
if (x=51)and(y=397)and(f3=true) then begin
f3:=false;
temps:=60*(10-niveau div 2);
putimage(360,43,barre^,normalput);
end;
if (x=555)and(y=397)and(f4=true) then begin
f4:=false;
temps:=60*(10-niveau div 2);
putimage(360,43,barre^,normalput);
end;
end;
{Route fantome}
tar:=false;
k:=1;
if i mod c=0 then begin
pf2:=pf;
repeat
randomize;
repeat
if (tar=true)or((pf2^.fa=162)and(pf2^.fo=145))or((pf2^.fa=219)and(pf2^.fo=145))
or((pf2^.fa=387)and(pf2^.fo=145))or((pf2^.fa=444)and(pf2^.fo=145))or((pf2^.fa=444)and(pf2^.fo=229))
or((pf2^.fa=444)and(pf2^.fo=313))or((pf2^.fa=387)and(pf2^.fo=313))or((pf2^.fa=162)and(pf2^.fo=313))
or((pf2^.fa=219)and(pf2^.fo=313))or((pf2^.fa=162)and(pf2^.fo=229)) then begin
if (k<3)and(temps=0)and(random(10)>2+(niveau div 2)) then begin
route(t,x,y,pf2^.fa,pf2^.fo);
pf2^.rf:=t[k];
k:=k+1;
end else pf2^.rf:=random(4)*2+2;
end;
if (pf2^.fa=304)and(pf2^.fo=174)and(pf2^.delais=0) then pf2^.rf:=8;
if (pf2^.fa=304)and(pf2^.fo=145)and(pf2^.rf=2) then pf2^.rf:=random(2)*2+4;;
if pf2^.rf=6 then if (getpixel(pf2^.fa+27,pf2^.fo)<>1)and(getpixel(pf2^.fa+27,pf2^.fo+26)<>1) then begin
pf2^.fa:=pf2^.fa+1; tar:=false; end else tar:=true;
if pf2^.rf=4 then if (getpixel(pf2^.fa-1,pf2^.fo)<>1)and(getpixel(pf2^.fa-1,pf2^.fo+26)<>1) then begin
pf2^.fa:=pf2^.fa-1; tar:=false; end else tar:=true;
if pf2^.rf=2 then if (getpixel(pf2^.fa,pf2^.fo+27)<>1)and(getpixel(pf2^.fa+26,pf2^.fo+27)<>1) then begin
pf2^.fo:=pf2^.fo+1; tar:=false; end else tar:=true;
if pf2^.rf=8 then if (getpixel(pf2^.fa,pf2^.fo-1)<>1)and(getpixel(pf2^.fa+26,pf2^.fo-1)<>1) then begin
pf2^.fo:=pf2^.fo-1; tar:=false; end else tar:=true;
until tar=false;
if (pf2^.fa=51)and(pf2^.fo=61) then
f1:=false;
if (pf2^.fa=555)and(pf2^.fo=61) then
f2:=false;
if (pf2^.fa=51)and(pf2^.fo=397) then
f3:=false;
if (pf2^.fa=555)and(pf2^.fo=397) then
f4:=false;
if pf2^.fa>570 then begin pf2^.fa:=35; putimage(570,229,blank^,normalput); end;
if pf2^.fa<35 then begin pf2^.fa:=570; putimage(35,229,blank^,normalput); end;
j:=1;
while (stock[j]<>0)and(j<24) do
j:=j+2;
if (pf2^.rf=6)and((getpixel(pf2^.fa+27,pf2^.fo+12)=14)
or(getpixel(pf2^.fa+27,pf2^.fo+14)=14))and(odd(pf2^.fa))
then begin
stock[j]:=pf2^.fa+27;
stock[j+1]:=pf2^.fo+13;
end;
if (pf2^.rf=4)and((getpixel(pf2^.fa-1,pf2^.fo+12)=14)or
(getpixel(pf2^.fa-1,pf2^.fo+14)=14))and(odd(pf2^.fa))
then begin
stock[j]:=pf2^.fa-2;
stock[j+1]:=pf2^.fo+13;
end;
if (pf2^.rf=2)and((getpixel(pf2^.fa+14,pf2^.fo+27)=14)or
(getpixel(pf2^.fa+12,pf2^.fo+27)=14))and(odd(pf2^.fo))
then begin
stock[j]:=pf2^.fa+13;
stock[j+1]:=pf2^.fo+27;
end;
if (pf2^.rf=8)and((getpixel(pf2^.fa+14,pf2^.fo-1)=14)
or(getpixel(pf2^.fa+12,pf2^.fo-1)=14))and(odd(pf2^.fo))
then begin
stock[j]:=pf2^.fa+13;
stock[j+1]:=pf2^.fo-1;
end;
pf3:=pf;
t1:=pf3^.fa;
t2:=pf3^.fo;
pf3:=pf3^.nxt;
t3:=pf3^.fa;
t4:=pf3^.fo;
pf3:=pf3^.nxt;
t5:=pf3^.fa;
t6:=pf3^.fo;
pf3:=pf3^.nxt;
t7:=pf3^.fa;
t8:=pf3^.fo;
for a:=1 to 6 do begin
j:=2*a-1;
if (stock[j]<>0)
and((t1>stock[j]+3)or(t1<stock[j]-32)
or(t2>stock[j+1]+3)or(t2<stock[j+1]-32))
and((t3>stock[j]+3)or(t3<stock[j]-32)
or(t4>stock[j+1]+3)or(t4<stock[j+1]-32))
and((t5>stock[j]+3)or(t5<stock[j]-32)
or(t6>stock[j+1]+3)or(t6<stock[j+1]-32))
and((t7>stock[j]+3)or(t7<stock[j]-32)
or(t8>stock[j+1]+3)or(t8<stock[j+1]-32))
then begin
putimage(stock[j],stock[j+1],fromage^,normalput);
stock[j]:=0;
end;
end;
if (temps=0)and(pf2^.delais=0) then putimage (pf2^.fa,pf2^.fo,fantome^,normalput);
if (pf2^.delais=0)and(temps>0) then putimage (pf2^.fa,pf2^.fo,vdt^,normalput);
if pf2^.delais>0 then begin
putimage(pf2^.fa,pf2^.fo,repos^,normalput);
pf2^.delais:=pf2^.delais-1;
end;
{Fantome bouff‚?}
if (getpixel(pf2^.fa+30,pf2^.fo+10)=6)or(getpixel(pf2^.fa-3,pf2^.fo+10)=6)
or(getpixel(pf2^.fa+15,pf2^.fo-3)=6)or(getpixel(pf2^.fa+15,pf2^.fo+30)=6) then begin
for j:=1 to 26 do begin
putimage(pf2^.fa,pf2^.fo+j,fade^,normalput);
if son=true then sound(j*100);
delay(500);
end;
nosound;
setcolor(0);
str(points,s);
outtextxy(220,40,s);
points:=points+500;
if (points div 4000)<>((points-500) div 4000) then bonus:=true;
setcolor(3);
str(points,s);
outtextxy(220,40,s);
pf2^.fa:=350;
pf2^.fo:=250;
pf2^.delais:=(10-niveau)*100;
end;
{bonus?}
if bonus=true then begin
bonus:=false;
if son=true then begin
for a:=1 to 4 do begin
sound(440*a);
delay(1000);
end;
nosound;
end;
setcolor(0);
str(vies,s);
outtextxy(105,40,s);
vies:=vies+1;
setcolor(3);
str(vies,s);
outtextxy(105,40,s);
end;
{fin?}
if (getpixel(pf2^.fa+30,pf2^.fo+10)=9)or(getpixel(pf2^.fa-3,pf2^.fo+10)=9)
or(getpixel(pf2^.fa+15,pf2^.fo-3)=9)or(getpixel(pf2^.fa+15,pf2^.fo+30)=9) then begin
setcolor(0);
str(vies,s);
outtextxy(105,40,s);
vies:=vies-1;
setcolor(3);
str(vies,s);
outtextxy(105,40,s);
pf2:=pf^.nxt;
for j:=1 to 26 do begin
putimage(x,y+j,fade^,normalput);
if son=true then sound(3000-j*100);
delay(500);
end;
nosound;
pf2:=pf;
repeat
putimage(pf2^.fa,pf2^.fo,blank^,normalput);
pf2:=pf2^.nxt;
until pf2=nil;
delay(5000);
if vies=0 then
perdu:=true;
if vies>0 then goto 1;
tar:=false;
end;
pf2:=pf2^.nxt;
until (pf2=nil)or(perdu=true);
end;
{Passage secret}
if x>570 then begin x:=35; putimage(570,229,blank^,normalput); end;
if x<35 then begin x:=570; putimage(35,229,blank^,normalput); end;
until (r=ord('q')-ord('0'))or(perdu=true)or(repas>214);
if repas>214 then begin
cleardevice;
outtextxy(220,30,'Prepare to next level');
while not(keypressed) do begin
delay(1000);
putimage(x,y,p2^.im,normalput);
p2:=p2^.nxt;
end;
if son=true then begin
for i:=1 to 3 do begin
sound(2000);
delay(1500);
nosound;
delay(500);
end;
sound(2000);
delay(12000);
nosound;
end;
end;
until (perdu=true)or(r=ord('q')-ord('0'));
repeat
for j:=1 to 25 do begin
for k:=1 to 2 do begin
if k=1 then setcolor(4) else setcolor(0);
outtextxy(290-3*j,20,'L');
outtextxy(300-j,20,'o');
outtextxy(310+j,20,'s');
outtextxy(320+3*j,20,'t');
if k=1 then delay(500);
end;
end;
for j:=25 downto 1 do begin
for k:=1 to 2 do begin
if (k=1) then setcolor(4) else setcolor(0);
outtextxy(290-3*j,20,'L');
outtextxy(300-j,20,'o');
outtextxy(310+j,20,'s');
outtextxy(320+3*j,20,'t');
if k=1 then delay(500);
end;
end;
until keypressed;
closegraph;
end.
|