Střílečka v Pascalu - druhá verze
Delphi & Pascal (česká wiki)
Kategorija: KMP (Programy mladňakoch
Zrobil: Miroslav Lízal, Tomáš Okurek
web: pascalweb.wz.cz/index86.html
Program: Stril2.pas
Subor exe: Stril2.exe
Zrobil: Miroslav Lízal, Tomáš Okurek
web: pascalweb.wz.cz/index86.html
Program: Stril2.pas
Subor exe: Stril2.exe
Jednoduchá střílečka dvou v Pascalu.
První hráč:
pohyb - kurzorové šípky
strělba - enter
Druhý hráč:
pohyb - A,S,D,W
strělba - mezerník
První hráč:
pohyb - kurzorové šípky
strělba - enter
Druhý hráč:
pohyb - A,S,D,W
strělba - mezerník
{ STRIL2.PAS Copyright (c) Miroslav Lízal, Tomá Okurek } { Jednoducha strilecka pro dva hrace - druha verze } { Prvni hrac: pohyb - kurzorove sipky } { strelba - enter } { Druhy hrac: pohyb - A,S,D,W } { strelba - mezernik } { } { Datum:15.01.2002 http://www.trsek.com } program posouvej; uses crt; type pole=array[1..2] of integer; var smer:pole; var zmiz1,xz1,yz1,x1,y1,shot1,sx1,sy1,cls1:integer; var zmiz2,xz2,yz2,x2,y2,shot2,sx2,sy2,cls2:integer; var i,klav,poc1,poc2:integer; begin; randomize; clrscr; textcolor(white); for i:=1 to 48 do begin gotoxy(79,i); write('|') end; textcolor(black); sx1:=0; sy1:=0; x1:=2; y1:=2; sx2:=0; sy2:=0; x2:=70; y2:=40; poc1:=0; poc2:=0; repeat textcolor(yellow); if shot1=1 then begin if smer[1]=75 then begin for i:=x1-1 downto 1 do begin gotoxy(i,y1); write('.'); end; if (x2<x1)and(y2=y1) then begin; poc1:=poc1+1; x2:=random(77)+1; y2:=random(47)+1;end;end; if smer[1]=77 then begin for i:=x1+1 to 78 do begin gotoxy(i,y1); write('.'); end; if (x2>x1)and(y2=y1) then begin; poc1:=poc1+1; x2:=random(77)+1; y2:=random(47)+1;end;end; if smer[1]=72 then begin for i:=y1-1 downto 1 do begin gotoxy(x1,i); write('.'); end; if (y2<y1)and(x2=x1) then begin; poc1:=poc1+1; x2:=random(77)+1; y2:=random(47)+1;end;end; if smer[1]=80 then begin for i:=y1+1 to 48 do begin gotoxy(x1,i); write('.'); end; if (y2>y1)and(x2=x1) then begin; poc1:=poc1+1; x2:=random(77)+1; y2:=random(47)+1;end;end; delay(25); if smer[1]=75 then begin for i:=x1 downto 1 do begin gotoxy(i,y1); write(' '); end; end; if smer[1]=77 then begin for i:=x1 to 78 do begin gotoxy(i,y1); write(' '); end; end; if smer[1]=72 then begin for i:=y1 downto 1 do begin gotoxy(x1,i); write(' '); end; end; if smer[1]=80 then begin for i:=y1 to 48 do begin gotoxy(x1,i); write(' '); end; end; shot1:=0; end; if shot2=1 then begin if smer[2]=97 then begin for i:=x2-1 downto 1 do begin gotoxy(i,y2); write('.'); end; if (x1<x2)and(y2=y1) then begin; poc2:=poc2+1; x1:=random(77)+1; y1:=random(47)+1;end;end; if smer[2]=100 then begin for i:=x2+1 to 78 do begin gotoxy(i,y2); write('.'); end; if (x1>x2)and(y2=y1) then begin; poc2:=poc2+1; x1:=random(77)+1; y1:=random(47)+1;end;end; if smer[2]=119 then begin for i:=y2-1 downto 1 do begin gotoxy(x2,i); write('.'); end; if (y1<y2)and(x2=x1) then begin; poc2:=poc2+1; x1:=random(77)+1; y1:=random(47)+1;end;end; if smer[2]=115 then begin for i:=y2+1 to 48 do begin gotoxy(x2,i); write('.'); end; if (y1>y2)and(x2=x1) then begin; poc2:=poc2+1; x1:=random(77)+1; y1:=random(47)+1;end;end; delay(25); if smer[2]=97 then begin for i:=x2 downto 1 do begin gotoxy(i,y2); write(' '); end; end; if smer[2]=100 then begin for i:=x2 to 78 do begin gotoxy(i,y2); write(' '); end; end; if smer[2]=119 then begin for i:=y2 downto 1 do begin gotoxy(x2,i); write(' '); end; end; if smer[2]=115 then begin for i:=y2 to 48 do begin gotoxy(x2,i); write(' '); end; end; shot2:=0; end; gotoxy(xz1,yz1);write(' '); gotoxy(xz2,yz2);write(' '); textcolor(red); if smer[1]=75 then begin gotoxy(x1,y1); write(chr(17)); end; if smer[1]=77 then begin gotoxy(x1,y1); write(chr(16)); end; if smer[1]=72 then begin gotoxy(x1,y1); write(chr(30)); end; if smer[1]=80 then begin gotoxy(x1,y1); write(chr(31)); end; textcolor(green); if smer[2]=97 then begin gotoxy(x2,y2); write(chr(17)); end; if smer[2]=100 then begin gotoxy(x2,y2); write(chr(16)); end; if smer[2]=119 then begin gotoxy(x2,y2); write(chr(30)); end; if smer[2]=115 then begin gotoxy(x2,y2); write(chr(31)); end; gotoxy(79,50); klav:=ord(readkey); if klav=0 then klav:=ord(readkey); xz1:=x1; yz1:=y1; xz2:=x2; yz2:=y2; if (klav=75) and not(x1=1 ) then begin x1:=x1-1; zmiz1:=1; smer[1]:=75; end; if (klav=77) and not(x1=78) then begin x1:=x1+1; zmiz1:=1; smer[1]:=77; end; if (klav=72) and not(y1=1 ) then begin y1:=y1-1; zmiz1:=1; smer[1]:=72; end; if (klav=80) and not(y1=48) then begin y1:=y1+1; zmiz1:=1; smer[1]:=80; end; if klav=13 then shot1:=1; if (klav=97) and not(x2=1 ) then begin x2:=x2-1; zmiz2:=1 ; smer[2]:=97;end; if (klav=100) and not(x2=78) then begin x2:=x2+1; zmiz2:=1; smer[2]:=100; end; if (klav=119) and not(y2=1 ) then begin y2:=y2-1; zmiz2:=1; smer[2]:=119; end; if (klav=115) and not(y2=48) then begin y2:=y2+1; zmiz2:=1; smer[2]:=115; end; if klav=32 then shot2:=1; textcolor(white);gotoxy(1,49);write('-------------------------------------------------------------------------------'); gotoxy(5,50);write('ZABIL:MRTEV '); textcolor(red);write(poc1,':',poc2,' '); textcolor(green);write(poc2,':',poc1); textcolor(white);write(' Celkove skore '); textcolor(red);write(poc1-poc2); textcolor(green);write(' ',poc2-poc1); until (klav=27); end.