Plošinovka s jedným levelom

Delphi & Pascal (česká wiki)
Přejít na: navigace, hledání
Kategória: KMP (Klub mladých programátorov)
hra.pngAutor: Peter Roob
Program: Hra.pas
Súbor exe: Hra.exe

Plošinovka s jedným levelom. Ovládate figúrku ktorá musí pozbierať všetko zlato a potom môže vyjsť dverami von. Pre prípad núdze máte k dispozícii život naviac a teleport.
{ HRA.PAS                                                           }
{                                                                   }
{ Author: Peter Roob                                                }
{ Date  : 02.02.2006                           http://www.trsek.com }
 
program hra;
uses graph,crt,dos;
var
x,y,z,a,b,c,d,e,f,g,v,i,j,k,l,m,n,o,p,q,r,s,t,u:integer;
h:char;
 
procedure pad;
 begin
 gotoxy(x+1,y);write(' ');
 gotoxy(x-1,y); write(' ');gotoxy(x,y);write('');delay(200);
 gotoxy(x,y);write(' ');gotoxy(x,y+1);write('');delay(200);
 gotoxy(x,y+1);write(' ');gotoxy(x,y+2);write('');delay(200);
 g:=x;
 y:=y+3;
 end;
 
procedure skokp;
 begin
 gotoxy(x,y); write(' '); gotoxy(x,y-1); write ('');delay(200);
 gotoxy(x,y-1);write(' ');gotoxy(x+1,y-1); write('');delay(200);
 gotoxy(x+1,y-1);write(' ');gotoxy(x+2,y-1);write('');delay(200);
 gotoxy(x+2,y-1);write(' ');gotoxy(x+2,y);write('');
 g:=x;
 x:=x+2;
 end;
 
procedure skokl;
 begin
 gotoxy(x,y); write(' '); gotoxy(x,y-1); write ('');delay(200);
 gotoxy(x,y-1);write(' ');gotoxy(x-1,y-1); write('');delay(200);
 gotoxy(x-1,y-1);write(' ');gotoxy(x-2,y-1);write('');delay(200);
 gotoxy(x-2,y-1);write(' ');gotoxy(x-2,y);write('');
 g:=x;
 x:=x-2;
 end;
 
procedure smrt;
 begin
 if z=1
 then
  begin
  z:=0;
  clrscr;
  textcolor(0);
  writeln('Si mrtvy');
  delay(1000);
  end;
 if z=2
 then
  begin
  a:=4;
  z:=1;
  end;
 end;
 
procedure zivot1;
 begin
  if b=1
  then
  begin
   if z=2
   then
    begin
    end;
   if z=1
   then
    begin
    z:=2;
    a:=6;
    c:=0;
    b:=0;
    end;
  end;
 end;
 
procedure kluc1;
 begin
 if e=1 then begin f:=f+1; end;
 e:=0;
 end;
 
procedure kluc2;
 begin
 if i=1 then begin f:=f+1; end;
 i:=0;
 end;
 
procedure kluc3;
 begin
 if j=1 then begin f:=f+1; end;
 j:=0;
 end;
 
procedure vitaz;
 begin
 if f=3 then v:=1;
 end;
 
                 {ZACIATOK}
begin
clrscr;
x:=10;
y:=9;
z:=2;
a:=6;
b:=1;
c:=1;
e:=1;
v:=0;
f:=0;
i:=1;
j:=1;
 
repeat
 clrscr;
 textbackground(7);
 clrscr;
 
 gotoxy(2,2);
 textcolor(0);
 write(chr(27),chr(26),'-Kurzorove sipky, ');
 write ('Skok doprava - Page Down, ');
 writeln ('Skok dolava - Delete');
 textcolor(4); write (' ',chr(3),'-Zivot ');
 textcolor(6); write (chr(5),'-Zlato ');
 textcolor(1); writeln (chr(219),'-Dvere,Koniec ');
 textcolor(1); write (' ',chr(176),'-Teleport        Pozbieraj vsetko zlato a ujdi dvermi!');
 
 gotoxy(10,6);
 if z=2 then begin textcolor(6); write('Zivot: 100%'); end;
 if z=1 then begin textcolor(4); write('Zivot: 50%');  end;
 {prostredie}
 if c=1 then begin gotoxy(19,9); textcolor(4); write(chr(3));end;
 if e=1 then begin gotoxy(21,9); textcolor(6); write(chr(5));end;
 if i=1 then begin gotoxy(43,15); textcolor(6); write(chr(5));end;
 if j=1 then begin gotoxy(25,15);textcolor(6); write(chr(5));end;
 gotoxy(10,10);
 textcolor(2);
 write(chr(219),chr(219),chr(219),chr(219),chr(219),' ',chr(219));
 textcolor(0);write(chr(30));
 textcolor(2);
 for d:=1 to 7 do write(chr(219));
 gotoxy(22,9); write(chr(219));
 gotoxy(7,13);
 for d:=1 to 23 do write(chr(219));
 textcolor(1);
 gotoxy(7,12);write(chr(176));gotoxy(45,15); write(chr(176));
 gotoxy(25,18);write(chr(176));
 gotoxy(18,12);write(chr(219));
 textcolor(2);
 gotoxy(7,16);
 for d:=1 to 5 do write(chr(219));textcolor(0);write(chr(30));
 textcolor(2); for d:=1 to 10 do write(chr(219));write(' ');
 for d:=1 to 6 do write(chr(219));
 for d:=1 to 11 do write(chr(219));
 for d:=1 to 5 do write(chr(219));
 gotoxy(29,15); write(chr(219));gotoxy(29,14); write(chr(219));
 gotoxy(7,19);
 for d:=1 to 40 do write(chr(219));
 
 
 textcolor(a);
 gotoxy(x,y);
 write ('');
 
 readkey;
 h:=readkey;
 
 if (h='M') then begin g:=x; x:=x+1; end;
 if (h='K') then x:=x-1;
 if (h=#81) then skokp;
 if (h=#83) then skokl;
 
 if ((x=15) and (y=9)) then pad;
 if ((x=17) and (y=9)) then smrt;
 if ((x=19) and (y=9)) then zivot1;
 if ((x=21) and (y=9)) then kluc1;
 if ((x=22) and (y=9)) then x:=g;
 if ((x=25) and (y=9)) then pad;
 if ((x=26) and (y=9)) then pad;
 if ((x=18) and (y=12)) then vitaz;
 if ((x=7) and (y=12)) then begin x:=10; y:=9; end;
 if ((x=9) and (y=9)) then pad;
 if ((x=8) and (y=9)) then pad;
 if ((x=30) and (y=12)) then pad;
 if ((x=31) and (y=12)) then pad;
 if ((x=12) and (y=15)) then smrt;
 if ((x=23) and (y=15)) then pad;
 if ((x=43) and (y=15)) then kluc2;
 if ((x=45) and (y=15)) then begin x:=8; y:=15; end;
 if ((x=25) and (y=15)) then kluc3;
 if ((x=25) and (y=18)) then begin x:=10; y:=9; end;
 if ((x=29) and (y=15)) then x:=g;
 
until ((h=#27) or (z=0) or (v=1));
 
clrscr;
textcolor(1);
gotoxy(20,20);
if z=0 then writeln ('GAME OVER');
if v=1 then writeln ('VITAZSTVO');
delay(2000);
 
end.