Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program grafika;
- uses graph,crt;
- type
- podKropki = record
- x,y,kolor : integer;
- end;
- wspIKolSam = record
- x,y,kolor : integer;
- end;
- all = record
- x,y,posx,posy,spd,cp1,cp2,cp3,cp4,li: integer;
- tabKrop : array [1..3,1..3] of podKropki;
- samoInf : array [1..10,1..10] of wspIKolSam;
- end;
- var
- ster,tryb:smallint;
- a:char;
- tab:array [1..4] of all;
- car:array [1..10,1..10,1..8] of byte; {grafika samochodzikow}
- flaga,fora,flaga2:integer;
- s,t:integer;
- tmp,tmp1,tmp2,licz,barx,samx,samy : integer;
- gr,ilgr: byte;
- ostRuch : char;
- label resetuje;
- const
- odstTex = 55; {odstep w poziomie miedzy menu i podmenu}
- dlT = 4;
- pozx_b = 100;
- pozy_b = 100; {wywalic}
- pozx_o = 300;
- pozy_o = 100;
- pozx_d = 500;
- pozy_d = 100;
- pozx_d2 = 300;
- pozy_d2 = 300;
- var
- tabMenuT : array [1..dlT,1..2] of string; {menuowska tablica}
- {-------------------------intro}
- function obetnij(lancuch:string;aktProc:real):string;
- var c : byte;wyn : string;
- begin
- wyn:='';
- for c:=1 to 4 do begin
- if lancuch[c]<>'.' then wyn:=wyn+lancuch[c];
- end;if aktProc<10 then wyn:=lancuch[1]+lancuch[2];if aktProc=100 then wyn:=wyn+'0';
- wyn:=wyn+'%';
- obetnij:=wyn;
- end;
- procedure samd(samx,samy:integer);
- begin
- putpixel(samx,samy,white);
- putpixel(samx+1,samy,white);
- putpixel(samx+1,samy+1,white);
- putpixel(samx,samy+1,white);
- putpixel(samx-1,samy-1,white);
- putpixel(samx-1,samy+2,white);
- putpixel(samx+2,samy+2,white);
- putpixel(samx+2,samy-1,white);
- putpixel(samx+2,samy+4,white);
- putpixel(samx+2,samy-3,white);
- putpixel(samx-2,samy-3,white);
- putpixel(samx-2,samy+4,white);
- line(samx-4,samy-2,samx+4,samy-2);
- line(samx-4,samy+3,samx+4,samy+3);
- line(samx-3,samy-3,samx-3,samy+4);
- line(samx-4,samy-3,samx-4,samy+4);
- line(samx+3,samy-3,samx+3,samy+4);
- line(samx+4,samy-2,samx+4,samy+3);
- end;
- procedure pasek;
- var
- proc : real; dx:integer;st : string;bylEnter : byte;
- begin
- dx:=0;bylEnter:=0;
- REPEAT
- setlinestyle(1,1,3);setfillstyle(9,blue);
- bar3d((getmaxx-500)div 2,getmaxy div 2,(getmaxx-500)div 2+dx,getmaxy div 2-50,10,true);
- dx:=dx+1;
- proc:=(dx / 500*100);
- str(proc,st);
- setlinestyle(0,1,1);bar((getmaxx+4) div 2,getmaxy div 2-25,(getmaxx+55) div 2,getmaxy div 2-17);
- outTextxy((getmaxx-3) div 2,(getmaxy-50) div 2,obetnij(st,proc));
- delay(5);
- samx:=((getmaxx-500)div 2);
- barx:=((getmaxx-500)div 2)-5;
- repeat
- setlinestyle(0,1,1);setfillstyle(9,black);
- samx:=samx+10;
- barx:=barx+10;
- samd(samx,300);
- bar(((getmaxx-500)div 2),295,barx,305);
- until samx>=((getmaxx-500)div 2+dx);
- if keypressed then bylEnter:=1;
- UNTIL (dx=500)OR(keypressed);
- if bylEnter=0 then delay(3000);cleardevice;
- end;
- {/ ---------------------------intro}
- {***GRAFIKA***}
- procedure beczka(pozx_b,pozy_b:integer);
- begin
- setlinestyle(0,0,1);
- SetColor(yellow);
- SetFillStyle(1,red);
- FillEllipse(pozx_b,pozy_b, 5, 3);
- Line(pozx_b-5,pozy_b,pozx_b-5,pozy_b+8);
- Line(pozx_b+5,pozy_b,pozx_b+5,pozy_b+8);
- FillEllipse(pozx_b,pozy_b+8, 5, 3);
- SetColor(red);
- Line(pozx_b-4,pozy_b+2,pozx_b-4,pozy_b+9);
- Line(pozx_b-3,pozy_b+3,pozx_b-3,pozy_b+9);
- Line(pozx_b-2,pozy_b+4,pozx_b-2,pozy_b+9);
- Line(pozx_b-1,pozy_b+4,pozx_b-1,pozy_b+9);
- Line(pozx_b,pozy_b+4,pozx_b,pozy_b+9);
- Line(pozx_b+1,pozy_b+4,pozx_b+1,pozy_b+9);
- Line(pozx_b+2,pozy_b+4,pozx_b+2,pozy_b+9);
- Line(pozx_b+3,pozy_b+3,pozx_b+3,pozy_b+9);
- Line(pozx_b+4,pozy_b+2,pozx_b+4,pozy_b+9);
- PutPixel(pozx_b,pozy_b+9,LightRed);
- PutPixel(pozx_b-1,pozy_b+9,LightRed);
- PutPixel(pozx_b-2,pozy_b+9,LightRed);
- PutPixel(pozx_b-3,pozy_b+8,LightRed);
- PutPixel(pozx_b-4,pozy_b+7,LightRed);
- PutPixel(pozx_b+1,pozy_b+9,LightRed);
- PutPixel(pozx_b+2,pozy_b+9,LightRed);
- PutPixel(pozx_b+3,pozy_b+8,LightRed);
- PutPixel(pozx_b+4,pozy_b+7,LightRed);
- PutPixel(pozx_b,pozy_b+8,LightRed);
- PutPixel(pozx_b-1,pozy_b+8,LightRed);
- PutPixel(pozx_b-2,pozy_b+8,LightRed);
- PutPixel(pozx_b-3,pozy_b+7,LightRed);
- PutPixel(pozx_b-4,pozy_b+6,LightRed);
- PutPixel(pozx_b+1,pozy_b+8,LightRed);
- PutPixel(pozx_b+2,pozy_b+8,LightRed);
- PutPixel(pozx_b+3,pozy_b+7,LightRed);
- PutPixel(pozx_b+4,pozy_b+6,LightRed);
- PutPixel(pozx_b+2,pozy_b,255);
- {PutPixel(pozx_b+2,pozy_b-1,black); }
- PutPixel(pozx_b+1,pozy_b-1,255);
- PutPixel(pozx_b+1,pozy_b,255);
- end;
- procedure odblask(pozx_o,pozy_o:integer);
- begin
- PutPixel(pozx_o-2+licz,pozy_o-2+licz,lightgray);
- PutPixel(pozx_o-3+licz,pozy_o-1+licz,lightgray);
- PutPixel(pozx_o-4+licz,pozy_o-1+licz,lightgray);
- PutPixel(pozx_o-5+licz,pozy_o-1+licz,lightgray);
- end;
- procedure olej_1(pozx_o,pozy_o:integer);
- begin randomize;
- SetColor(blue);
- SetFillStyle(1,blue);
- FillEllipse(pozx_o,pozy_o, 5, 3);
- for tmp:=1 to 10 do
- begin
- FillEllipse(pozx_o+(random(15)),pozy_o+(random(15)), 5, 3);
- end;
- for tmp:=1 to 3 do
- begin
- licz:=licz+random(8);
- odblask(pozx_o,pozy_o);
- end;
- end;
- procedure drzewo_1(pozx_d,pozy_d:integer);
- begin
- SetColor(yellow);
- Line(pozx_d,pozy_d+6,pozx_d+10,pozy_d+16);
- Line(pozx_d,pozy_d+6,pozx_d-10,pozy_d+16);
- Line(pozx_d+10,pozy_d+16,pozx_d-10,pozy_d+16);
- {floodfill(pozx_d,pozy_d+8,green);}
- Line(pozx_d,pozy_d+16,pozx_d+12,pozy_d+26);
- Line(pozx_d,pozy_d+16,pozx_d-12,pozy_d+26);
- Line(pozx_d-12,pozy_d+26,pozx_d+12,pozy_d+26);
- Line(pozx_d,pozy_d+26,pozx_d+16,pozy_d+36);
- Line(pozx_d,pozy_d+26,pozx_d-16,pozy_d+36);
- Line(pozx_d-16,pozy_d+36,pozx_d+16,pozy_d+36);
- Rectangle(pozx_d-2,pozy_d+36,pozx_d+2,pozy_d+44);
- SetFillStyle(1,brown);
- {floodfill(pozx_d,pozy_d+40,brown);}
- end;
- procedure drzewo_2(pozx_d,pozy_d:integer);
- begin
- SetColor(green);
- SetFillStyle(6{6},green);
- FillEllipse(pozx_d2,pozy_d2, 8, 4);
- FillEllipse(pozx_d2-4,pozy_d2+2, 8, 4);
- FillEllipse(pozx_d2+4,pozy_d2+2, 8, 4);
- FillEllipse(pozx_d2,pozy_d2+4, 8, 4);
- FillEllipse(pozx_d2-6,pozy_d2+5, 8, 4);
- FillEllipse(pozx_d2+6,pozy_d2+6, 8, 4);
- FillEllipse(pozx_d2-8,pozy_d2+10, 8, 4);
- FillEllipse(pozx_d2+9,pozy_d2+10, 8, 4);
- FillEllipse(pozx_d2,pozy_d2+13, 8, 4);
- FillEllipse(pozx_d2+9,pozy_d2+18, 8, 4);
- FillEllipse(pozx_d2-9,pozy_d2+17, 8, 4);
- FillEllipse(pozx_d2-2,pozy_d2+17, 8, 4);
- FillEllipse(pozx_d2-7,pozy_d2+22, 8, 4);
- FillEllipse(pozx_d2+7,pozy_d2+23, 8, 4);
- FillEllipse(pozx_d2+8,pozy_d2+25, 8, 4);
- FillEllipse(pozx_d2+5,pozy_d2+28, 8, 4);
- FillEllipse(pozx_d2-6,pozy_d2+25, 8, 4);
- FillEllipse(pozx_d2-4,pozy_d2+28, 8, 4);
- FillEllipse(pozx_d2-3,pozy_d2+30, 8, 4);
- FillEllipse(pozx_d2+3,pozy_d2+30, 8, 4);
- SetFillStyle(1,brown);
- SetColor(brown);
- Rectangle(pozx_d2-2,pozy_d2+34,pozx_d2+2,pozy_d2+45);
- {floodfill(pozx_d2,pozy_d2+40,brown);}
- end;
- procedure mapa(ktoraMapa:byte);
- begin
- case ktoraMapa of
- 1: begin {elipsa}
- ellipse(300,240,0,360,180,220);
- ellipse(300,240,0,360,100,120);
- setfillstyle(1,green);
- floodfill(320,240,white);
- floodfill(1,1,white);
- line(120,240,200,240);
- end;
- 2:
- begin {kffiatek}
- setfillstyle(1,green);
- bar(0,0,640,480);
- setcolor(white);
- ellipse(320,240,30,150,70,220);
- ellipse(320,240,210,330,70,220);
- ellipse(320,240,45,135,30,140);
- ellipse(320,240,225,315,30,140);
- ellipse(320,240,0,60,220,70);
- ellipse(320,240,300,360,220,70);
- ellipse(320,240,120,240,220,70);
- ellipse(320,240,0,45,140,30);
- ellipse(320,240,315,360,140,30);
- ellipse(320,240,135,225,140,30);
- ellipse(200,120,277,353,101,101);
- ellipse(200,120,275,355,60,60);
- ellipse(440,120,187,263,101,101);
- ellipse(440,120,185,265,60,60);
- ellipse(200,360,7,83,101,101);
- ellipse(200,360,5,85,60,60);
- ellipse(440,360,97,173,101,101);
- ellipse(440,360,95,175,60,60);
- setfillstyle(1,0);
- floodfill(180,240,white);
- setlinestyle(dashedln,0,3);
- for tmp1:=45 to 135 do
- begin
- if tmp1 mod 6 = 0 then
- begin
- tmp2:=tmp2+1;
- if tmp2 mod 2 = 0 then setcolor(red) else setcolor(white);
- ellipse(320,240,tmp1,tmp1+5,30,140);
- end;
- {setlinestyle(0,0,3);}
- end;
- end;
- end;
- end;
- {samochodziki}
- procedure wzorSam(samx,samy:integer;wybor:char);
- begin
- case wybor of
- 'w' : begin {gora}
- putpixel(samx,samy,white);
- putpixel(samx+1,samy,white);
- putpixel(samx,samy+1,white);
- putpixel(samx+1,samy+1,white);
- putpixel(samx-1,samy-1,white);
- putpixel(samx-1,samy+2,white);
- putpixel(samx+2,samy-1,white);
- putpixel(samx+2,samy+2,white);
- putpixel(samx-3,samy+3,white);
- putpixel(samx+4,samy+3,white);
- putpixel(samx-3,samy-1,white);
- putpixel(samx+4,samy-1,white);
- line(samx-3,samy-2,samx+4,samy-2);
- line(samx-2,samy-3,samx+3,samy-3);
- line(samx-2,samy-4,samx+3,samy-4);
- line(samx-2,samy+5,samx-2,samy-4);
- line(samx+3,samy+5,samx+3,samy-4);
- line(samx-3,samy+4,samx+4,samy+4);
- line(samx-3,samy+5,samx+4,samy+5);
- end;
- 'q' : begin
- putpixel(samx-2,samy-2,white);
- putpixel(samx+1,samy+1,white);
- putpixel(samx-2,samy+2,white);
- putpixel(samx-1,samy+2,white);
- putpixel(samx+2,samy-2,white);
- putpixel(samx+2,samy-1,white);
- putpixel(samx-4,samy-1,white);
- putpixel(samx-1,samy-4,white);
- line(samx-3,samy,samx+4,samy);
- line(samx,samy-3,samx,samy+4);
- line(samx-3,samy-2,samx-3,samy+1);
- line(samx-2,samy-3,samx+1,samy-3);
- line(samx+1,samy+4,samx+4,samy+1);
- line(samx+1,samy+5,samx+5,samy+1);
- line(samx+2,samy+5,samx+5,samy+2);
- end;
- end;
- end;
- procedure macheSamo(ktory : byte);{ktory samochod i wsplorzedne}
- var i,j,m1,m2,kolor,getKolor : integer;
- begin
- m1:=tab[gr].posx-4;m2:=tab[gr].posy-4;
- for i:=1 to 10 do begin
- for j:=1 to 10 do begin
- if car[i,j,ktory]=1 then
- begin
- if gr=1 then kolor:=cyan;
- if gr=2 then kolor:=yellow;
- if gr=3 then kolor:=red;
- if gr=4 then kolor:=lightgreen;
- getKolor:=getpixel(i+m1,j+m2);
- if (getKolor<>cyan)AND(getKolor<>yellow)AND(getKolor<>red)AND(getKolor<>lightgreen) then begin
- tab[gr].samoInf[i,j].kolor:=getKolor;
- tab[gr].samoInf[i,j].x:=i+m1;tab[gr].samoInf[i,j].y:=j+m2;
- end;
- putpixel(i+m1,j+m2,kolor);
- end;
- end;
- end;
- end;
- procedure sprzSamo;
- var i,j,m1,m2 : integer;
- begin
- for i:=1 to 10 do begin
- for j:=1 to 10 do begin
- putpixel(tab[gr].samoInf[i,j].x,tab[gr].samoInf[i,j].y,tab[gr].samoInf[i,j].kolor);
- end;
- end;
- end;
- procedure doTaba(ktoreCar : byte); {zapisanie wszystkich samochodow do car}
- var x,y,x1,y1,z : integer;
- f : text;
- begin
- case ktoreCar of
- 1:begin {prosty}
- Assign(F, 'sam.txt');
- Rewrite(F);
- for x:=1 to 10 do begin
- for y:=1 to 10 do begin
- if getpixel(x,y)=white then car[x,y,1]:=1 else car[x,y,1]:=0;
- Write(F, car[x,y,1],' ');
- end;
- writeln(F,'');
- end;
- Close(F);
- cleardevice;
- Assign(F, 'sam.txt');
- Reset(F);
- for x:=1 to 10 do begin
- for y:=10 downto 1 do begin
- Read(F,car[x,y,2]);
- end;
- readln(F);
- end;
- reset(F);
- for x:=1 to 10 do begin
- for y:=10 downto 1 do begin
- read(F,car[y,x,3]);
- end;
- readln(F);
- end;
- reset(f);
- for x:=1 to 10 do begin
- for y:=1 to 10 do begin
- read(f,car[y,x,4]);
- end;
- readln(f);
- end;
- Close(F);
- end;
- 2:begin {ukos}
- Assign(F, 'sam1.txt');
- Rewrite(F);
- for x:=1 to 10 do begin
- for y:=1 to 10 do begin
- if getpixel(x,y)=white then car[x,y,5]:=1 else car[x,y,5]:=0;
- Write(F, car[x,y,5],' ');
- end;
- writeln(F,'');
- end;
- Close(F);
- Assign(F, 'sam1.txt');
- Reset(F);
- Begin
- for x:=1 to 10 do begin
- for y:=10 downto 1 do begin
- Read(F,car[x,y,6]);
- end;
- end;
- readln(F);
- end;
- reset(f);
- for x:=1 to 10 do begin
- for y:=10 downto 1 do begin
- read(f,car[y,x,7]);
- end;
- readln(f);
- end;
- reset(f);
- for x:=10 downto 1 do begin
- for y:=10 downto 1 do begin
- read(f,car[x,y,8]);
- end;
- readln(f);
- end;
- Close(F);
- end;
- end;
- end;
- procedure genSam(ruch:char);
- var i : byte;st : string;
- begin
- st:='wxdaqzec';
- for i:=1 to length(st) do begin
- if ruch = st[i] then macheSamo(i);
- end;
- end;
- procedure zaladujSamochody;
- begin
- wzorSam(5,5,'w');doTaba(1);cleardevice;wzorSam(5,5,'q'); doTaba(2); cleardevice;
- end;
- {***KONIEC GRAFIKI***}
- procedure mozliwe(s,t : integer;wypCzys : byte);
- var i,j : byte;
- begin i:=0;
- s:=tab[gr].posx-tab[gr].x-9;
- REPEAT
- i:=i+1;j:=0;t:=tab[gr].posy-tab[gr].y-9;
- REPEAT
- j:=j+1;
- if wypCzys=1 then begin {przed ruchem}
- tab[gr].tabKrop[i,j].x:=s;
- tab[gr].tabKrop[i,j].y:=t;
- tab[gr].tabKrop[i,j].kolor:=getpixel(s,t);
- if gr=1 then putpixel(s,t,cyan);
- if gr=2 then putpixel(s,t,yellow);
- if gr=3 then putpixel(s,t,red);
- if gr=4 then putpixel(s,t,lightgreen);
- {putpixel(s,t,15);} {po ruchu}
- end ELSE putpixel(tab[gr].tabKrop[i,j].x,tab[gr].tabKrop[i,j].y,tab[gr].tabKrop[i,j].kolor);
- t:=t+9;
- UNTIL j=3;
- s:=s+9;
- UNTIL i=3;
- end;
- {*** sekcja menu ***}
- procedure wysAktMenu(wybor,ktoreMenu : byte); {do wyswietlania menu}
- var i,j : byte;
- begin
- j:=3;
- for i:=1 to dlT do begin
- setColor(white);
- if wybor=i then begin
- setColor(red);
- end;
- outTextXY((getmaxx-length(tabMenuT[i,ktoreMenu])) div 2+(ktoreMenu-1)*odstTex,getmaxy div 2-j*10,tabMenuT[i,ktoreMenu]);
- j:=j-1;
- end;
- end;
- procedure menuTablica; {optymalizacja, zeby rekurencyjnie}
- begin {nie nadpisywal tablicy pare raz}
- {glowneMenu}
- tabMenuT[1,1]:='Start';
- tabMenuT[2,1]:='Opcje';
- tabMenuT[3,1]:='About';
- tabMenuT[4,1]:='Koniec';
- {podMenu}
- tabMenuT[1,2]:='1 gracz';
- tabMenuT[2,2]:='2 graczy';
- tabMenuT[3,2]:='3 graczy';
- tabMenuT[4,2]:='4 graczy';
- end;
- procedure menu(menuPod : byte); {interakcja z uzytkownikiem (tyko zmiana wartosci)}
- var wyborMenu : char;wyborLicz : shortint;wyborLicz1,wyborLicz2,przed1,przed2,i,j : byte;
- {tabMenuT : array [1..3] of string;}
- begin
- wyborLicz:=1;
- wysAktMenu(1,menuPod);
- REPEAT
- wyborMenu:=readkey;
- case wyborMenu of
- 'w','W':begin wyborLicz:=wyborLicz-1; end;
- 's','S':begin wyborLicz:=wyborLicz+1; end;
- 'a','A':begin menuPod:=menuPod-1;
- if menuPod=0 then menuPod:=1;
- cleardevice;
- for i:=1 to menuPod do begin wysAktMenu(1,i);end;menu(menuPod);break;end;
- end;
- if wyborLicz=0 then wyborLicz:=4;
- if wyborLicz=5 then wyborLicz:=1;
- case menuPod of
- 1:begin wyborLicz1:=wyborLicz; end;{glowne}
- 2:begin wyborLicz2:=wyborLicz; end;
- end;
- wysAktMenu(wyborLicz,menuPod);
- UNTIL (wyborMenu=#13)OR(wyborMenu='a')OR(wyborMenu='D')OR(wyborMenu='d');
- if menuPod = 1 then begin
- if wyborLicz1 = 1 then begin cleardevice;{mapa(2);}end;
- if wyborLicz1 = 2 then begin menu(2);end;
- if wyborLicz1 = 3 then begin outtextxy(1,1,'Autorzy');readkey;cleardevice;menu(1);end;
- if wyborLicz1 = 4 then halt;
- end;
- if menuPod = 2 then begin
- if wyborLicz2 = 1 then ilGr:=1;
- if wyborLicz2 = 2 then ilGr:=2;
- if wyborLicz2 = 3 then ilGr:=3;
- if wyborlicz2 = 4 then ilGr:=4;
- menuPod:=menuPod-1;
- cleardevice;
- menu(menuPod);
- end;
- end;
- {/ menu}
- procedure dane;
- var
- st:string;
- begin
- settextstyle(1,0,1); outtextxy(513,420,'SPEED:'); str(tab[gr].spd,st); outtextxy(605,420,st);
- outtextxy(513,435,'RUCH NR:'); str(tab[gr].li,st); outtextxy(605,435,st);
- end;
- procedure hud(gr:byte);
- var st,st1 : string;
- begin
- setfillstyle(1,0);
- bar(500,390,630,470);
- settextstyle(1,0,2);
- if gr=1 then setcolor(cyan);
- if gr=2 then setcolor(yellow);
- if gr=3 then setcolor(red);
- if gr=4 then setcolor(lightgreen);
- st:='GRACZ';str(gr,st1);
- st:=st+' '+st1;
- outtextxy(513,395,st);dane;
- end;
- procedure sprawdzcp;
- var tmp1:byte;
- begin
- if (tab[gr].posx>460) and (tab[gr].posx<540) and (tab[gr].posy>180) and (tab[gr].posy<300) then tab[gr].cp1:=tab[gr].cp1+1;
- if (tab[gr].posx>100) and (tab[gr].posx<180) and (tab[gr].posy>180) and (tab[gr].posy<240) then tab[gr].cp2:=tab[gr].cp2+1;
- if (tab[gr].posx>260) and (tab[gr].posx<380) and (tab[gr].posy>380) and (tab[gr].posy<460) then tab[gr].cp3:=tab[gr].cp3+1;
- if (tab[gr].posx>260) and (tab[gr].posx<380) and (tab[gr].posy>20) and (tab[gr].posy<100) then
- begin
- tab[gr].cp4:=tab[gr].cp4+1;
- tab[gr].cp1:=0;
- end;
- { writeln(tab[gr].cp1,' ',tab[gr].cp2,' ',tab[gr].cp3,' ',tab[gr].cp4);} {na off bo sprawdzam samochody}
- {bar(460,180,540,300);
- bar(100,180,180,240); pozycje cp
- bar(260,380,380,460);
- bar(260,20,380,100);}
- if (tab[gr].cp1>0) and (tab[gr].cp2>0) and (tab[gr].cp3>0) and (tab[gr].cp4>0) then
- outtextxy(20,20,'PANIE KMIE CHECKPOINTY DZIALAJA, BEZ ODBIORU');
- end;
- {***GLOWNY BEGIN***}
- begin
- ster:=VGA; tryb:=VGAHi; gr:=1;
- InitGraph(ster, tryb, '');
- ilGr:=2; ostRuch:='w';
- resetuje:
- pasek;readkey; {pasek ladowania - mozna rypnac intro}
- zaladujSamochody;menuTablica;
- menu(1);
- tab[1].posx:=170; tab[1].posy:=240;
- tab[2].posx:=150; tab[2].posy:=240; {pozycja startowa}
- tab[3].posx:=130; tab[3].posy:=240;
- tab[4].posx:=110; tab[4].posy:=240;
- tab[1].li:=1;
- tab[2].li:=1;
- tab[3].li:=1;
- tab[4].li:=1;
- mapa(2);
- hud(gr);
- gr:=1;
- olej_1(pozx_o,pozy_o); beczka(pozx_b,pozy_b);
- drzewo_1(pozx_d,pozy_d);drzewo_2(pozx_d2,pozy_d2);
- flaga:=0;
- REPEAT
- hud(gr);
- mozliwe(tab[gr].posx-tab[gr].x,tab[gr].posy-tab[gr].y,1); {rysuj kropki}
- a:=readkey;
- sprzSamo;
- case a of
- 'q','Q':begin tab[gr].y:=tab[gr].y+10; tab[gr].x:=tab[gr].x+10; flaga2:=1; end;
- 'w','W':begin tab[gr].y:=tab[gr].y+10; flaga2:=1; end;
- 'e','E':begin tab[gr].y:=tab[gr].y+10; tab[gr].x:=tab[gr].x-10; flaga2:=1; end;
- 'a','A':begin tab[gr].x:=tab[gr].x+10; flaga2:=1; end;
- 's','S':begin tab[gr].y:=tab[gr].y+0; tab[gr].x:=tab[gr].x+0; flaga2:=1; end;
- 'd','D':begin tab[gr].x:=tab[gr].x-10; flaga2:=1; end;
- 'z','Z':begin tab[gr].y:=tab[gr].y-10; tab[gr].x:=tab[gr].x+10; flaga2:=1; end;
- 'x','X':begin tab[gr].y:=tab[gr].y-10; flaga2:=1; end;
- 'c','C':begin tab[gr].y:=tab[gr].y-10; tab[gr].x:=tab[gr].x-10; flaga2:=1; end;
- 'l':begin cleardevice; goto resetuje; end;
- end;
- if flaga2=1 then
- begin
- if getpixel(tab[gr].posx-tab[gr].x,tab[gr].posy-tab[gr].y)=green then flaga:=1;
- if gr=1 then setcolor(cyan);
- if gr=2 then setcolor(yellow);
- if gr=3 then setcolor(red);
- if gr=4 then setcolor(lightgreen);
- setlinestyle(dottedln,0,1);
- line(tab[gr].posx,tab[gr].posy,tab[gr].posx-tab[gr].x,tab[gr].posy-tab[gr].y);
- tab[gr].posx:=tab[gr].posx-tab[gr].x;
- tab[gr].posy:=tab[gr].posy-tab[gr].y;
- if flaga=1 then {wjazd na pobocze}
- begin
- tab[gr].x:=0;
- tab[gr].y:=0;
- flaga:=0;
- end;
- if tab[gr].x>tab[gr].y then tab[gr].spd:=tab[gr].x else tab[gr].spd:=tab[gr].y; {szybkosc}
- {setlinestyle(0,0,1);
- circle(tab[gr].posx,tab[gr].posy,3);}
- if a<>'s' then ostRuch:=a ELSE a:=ostRuch;
- genSam(a);
- sprawdzcp;
- mozliwe(tab[gr].posx-tab[gr].x,tab[gr].posy-tab[gr].y,2);
- tab[gr].li:=tab[gr].li+1;
- gr:=gr+1;
- if gr=ilgr+1 then gr:=1;
- flaga2:=0;
- hud(gr);
- end;
- UNTIL (a='b') or (a='B');
- closegraph;
- end.
Advertisement
Add Comment
Please, Sign In to add comment