Код
program igra;
uses crt, graph;
const
left = #75;
right = #77;
up = #72;
down = #80;
var
driver, mode : Integer;
x, y, b, i, g, f,d, e, score: integer;
c: char;
mineXe:array [1..100] of integer;
mineYe: array [1..100] of integer;
{-----------------------------------------------}
procedure redestroy;
var x,y,n,m, a,b , c, d,e, f , g, i:integer;
var u:word;
vybor:integer;
Begin
driver:= 9;
mode:= 1;
initgraph(driver, mode, 'c:\bp\bgi');
setActivePage(0);
setvisualpage(0);
setfillstyle(ltslashfill, white);
bar(40, 20,600, 250);
setfillstyle(solidfill, lightred);
bar (60, 40 , 150 , 90);
setfillstyle(solidfill, lightgreen);
bar (60, 110, 150, 160);
setfillstyle(solidfill, lightblue);
bar(60, 180, 150, 230);
outTextXY (70, 65, 'power_ON');
randomize;
a:=random(2) + 1;
b:=((a+1) mod 3) + 1;
c:=((b+1) mod 3) + 1;
setcolor( green);
f:=150;
g:=65;
for i:= 1 to 5 do begin
d:= (random(400)+100);
e:= (random(150) + 100);
line(f, g, d, e);
f:= (random(400)+100);
g:= (random(150) + 100);
line (d,e,f,g);
end;
setfillstyle( solidFill, yellow);
pieslice(500, 60,0,360, 10);
case a of
1: line(f, g, 500, 60);
2: line(f,g, 500, 140);
3: line(f,g, 500, 220);
end;
setcolor( green);
f:=150;
g:=135;
for i:= 1 to 5 do begin
d:= (random(400)+150);
e:= (random(150) + 100);
line(f, g, d, e);
f:= (random(400)+150);
g:= (random(150) + 100);
line (d,e,f,g);
end;
setfillstyle( solidfill, yellow);
pieslice(500, 140,0,360, 10);
case b of
1: line(f, g, 500, 60);
2: line(f,g, 500, 140);
3: line(f,g, 500, 220);
end;
setcolor( green);
f:=150;
g:=205;
for i:= 1 to 5 do begin
d:= (random(400)+200);
e:= (random(150) + 100);
line(f, g, d, e);
f:= (random(400)+200);
g:= (random(150) + 100);
line (d,e,f,g);
end;
setfillstyle( solidFill, yellow);
pieslice(500, 220,0,360, 10);
case c of
1: line(f, g, 500, 60);
2: line(f,g, 500, 140);
3: line(f,g, 500, 220);
end;
read(vybor);
case vybor of
1 : case a of
1:begin
readln;
closegraph;
clrscr;
setcolor(lightred);
gotoxy(35,3);
writeln('Mine was destroyed');
readln;
end;
2:begin
closegraph;
clrscr;
setcolor(lightred);
gotoxy(35,3);
writeln('You lose!!');
gotoxy(35,4);
writeln(score);
readln;
halt;
end;
3: begin
closegraph;
clrscr;
setcolor(lightred);
gotoxy(35,3);
writeln('You lose!!');
gotoxy(35,4);
writeln(score);
readln;
halt;
end;
end;
2: case a of
3:begin
closegraph;
clrscr;
setcolor(lightred);
gotoxy(35,3);
writeln('Mine was destroyed');
end;
2:begin
closegraph;
clrscr;
setcolor(lightred);gotoxy(35,3);
writeln('You lose!!');
gotoxy(35,4);
writeln(score);
readkey;
halt;
end;
1: begin
readln;
closegraph;
clrscr;
setcolor(lightred);
gotoxy(35,3);
writeln('You lose!!');
gotoxy(35,4);
writeln(score);
readln;
end;
end;
3 : case a of
2:begin
closegraph;
clrscr;
setcolor(lightred);
gotoxy(35,3);
writeln('Mine was destroyed');
end;
1:begin
closegraph;
clrscr;
setcolor(lightred);
gotoxy(35,3);
writeln('You lose!!');
gotoxy(35,4);
writeln(score);
readln;
Halt;
end;
3: begin
closegraph;
clrscr;
setcolor(lightred);
gotoxy(35,3);
writeln('You lose!!');
gotoxy(35,4);
writeln(score);
readln;
halt;
end;
end;
end;
end;
{-----------------------------------------------}
procedure net;
begin
for i:= 1 to 10 do
if ((x=minexe[i]) and ( y=mineye[i]-1)) or ((x=minexe[i]-2) and ( y=mineye[i]-1)) then begin
redestroy;
end;
end;
{-----------------------------------------------}
procedure show_man;
begin
textcolor(yellow);
gotoxy(x, y+0); write(' O');
gotoxy(x, y+1); write('XXX');
gotoxy(x, y+2); write(' X');
gotoxy(x, y+3); write('X X');
end;
{-----------------------------------------------}
procedure fill;
begin
randomize;
for i:= 1 to 10 do begin
minexe[i]:=random(80);
mineye[i]:=random(24);
end;
end;
{-----------------------------------------------}
procedure boom;
begin
for i:=1 to 10 do begin
if (minexe[i]<>0) and (mineye[i]<>0) then begin
textcolor(red);
gotoxy(minexe[i], mineye[i]); write('@');
end;
end;
end;
{-----------------------------------------------}
procedure min;
begin
for i:= 1 to 10 do begin
if (x=minexe[i]) and ( y=mineye[i]-3)or ((x=minexe[i]-2) and ( y=mineye[i]-3)) then begin
clrscr;
textcolor(lightred);
gotoxy(35,3); writeln('You are dead!!!');
gotoxy(35,4); writeln('Your score was:', score);
textcolor(lightgray);
readkey; halt;
end;
end;
end;
begin
score:=0;
clrscr;
gotoxy(35,3); writeln('Choose level:');
gotoxy(35,4); writeln('1. Legko');
gotoxy(35,5); writeln('2. Slozno');
read(d);
case d of
1: d:=150;
2: d:=50;
end;
b := 0;
x :=5; y :=20;
fill;
show_man;
boom; min;
repeat
c:=readkey;
case c of
#13:begin
gotoxy(35,3); writeln('Your score is:', score);
readln;
end;
#32: net;
#0:
case readkey of
left : dec(x);
right: inc(x);
up : dec(y);
down : inc(y);
end;
end;
clrscr;
show_man;
boom; min;
b:=b+1;
if score= 10 then begin
b:=d;
clrscr;
gotoxy(35,3);
textcolor(White);
writeln('You win the game!!!');
readkey;
end;
until b=d;
readkey;
end.
uses crt, graph;
const
left = #75;
right = #77;
up = #72;
down = #80;
var
driver, mode : Integer;
x, y, b, i, g, f,d, e, score: integer;
c: char;
mineXe:array [1..100] of integer;
mineYe: array [1..100] of integer;
{-----------------------------------------------}
procedure redestroy;
var x,y,n,m, a,b , c, d,e, f , g, i:integer;
var u:word;
vybor:integer;
Begin
driver:= 9;
mode:= 1;
initgraph(driver, mode, 'c:\bp\bgi');
setActivePage(0);
setvisualpage(0);
setfillstyle(ltslashfill, white);
bar(40, 20,600, 250);
setfillstyle(solidfill, lightred);
bar (60, 40 , 150 , 90);
setfillstyle(solidfill, lightgreen);
bar (60, 110, 150, 160);
setfillstyle(solidfill, lightblue);
bar(60, 180, 150, 230);
outTextXY (70, 65, 'power_ON');
randomize;
a:=random(2) + 1;
b:=((a+1) mod 3) + 1;
c:=((b+1) mod 3) + 1;
setcolor( green);
f:=150;
g:=65;
for i:= 1 to 5 do begin
d:= (random(400)+100);
e:= (random(150) + 100);
line(f, g, d, e);
f:= (random(400)+100);
g:= (random(150) + 100);
line (d,e,f,g);
end;
setfillstyle( solidFill, yellow);
pieslice(500, 60,0,360, 10);
case a of
1: line(f, g, 500, 60);
2: line(f,g, 500, 140);
3: line(f,g, 500, 220);
end;
setcolor( green);
f:=150;
g:=135;
for i:= 1 to 5 do begin
d:= (random(400)+150);
e:= (random(150) + 100);
line(f, g, d, e);
f:= (random(400)+150);
g:= (random(150) + 100);
line (d,e,f,g);
end;
setfillstyle( solidfill, yellow);
pieslice(500, 140,0,360, 10);
case b of
1: line(f, g, 500, 60);
2: line(f,g, 500, 140);
3: line(f,g, 500, 220);
end;
setcolor( green);
f:=150;
g:=205;
for i:= 1 to 5 do begin
d:= (random(400)+200);
e:= (random(150) + 100);
line(f, g, d, e);
f:= (random(400)+200);
g:= (random(150) + 100);
line (d,e,f,g);
end;
setfillstyle( solidFill, yellow);
pieslice(500, 220,0,360, 10);
case c of
1: line(f, g, 500, 60);
2: line(f,g, 500, 140);
3: line(f,g, 500, 220);
end;
read(vybor);
case vybor of
1 : case a of
1:begin
readln;
closegraph;
clrscr;
setcolor(lightred);
gotoxy(35,3);
writeln('Mine was destroyed');
readln;
end;
2:begin
closegraph;
clrscr;
setcolor(lightred);
gotoxy(35,3);
writeln('You lose!!');
gotoxy(35,4);
writeln(score);
readln;
halt;
end;
3: begin
closegraph;
clrscr;
setcolor(lightred);
gotoxy(35,3);
writeln('You lose!!');
gotoxy(35,4);
writeln(score);
readln;
halt;
end;
end;
2: case a of
3:begin
closegraph;
clrscr;
setcolor(lightred);
gotoxy(35,3);
writeln('Mine was destroyed');
end;
2:begin
closegraph;
clrscr;
setcolor(lightred);gotoxy(35,3);
writeln('You lose!!');
gotoxy(35,4);
writeln(score);
readkey;
halt;
end;
1: begin
readln;
closegraph;
clrscr;
setcolor(lightred);
gotoxy(35,3);
writeln('You lose!!');
gotoxy(35,4);
writeln(score);
readln;
end;
end;
3 : case a of
2:begin
closegraph;
clrscr;
setcolor(lightred);
gotoxy(35,3);
writeln('Mine was destroyed');
end;
1:begin
closegraph;
clrscr;
setcolor(lightred);
gotoxy(35,3);
writeln('You lose!!');
gotoxy(35,4);
writeln(score);
readln;
Halt;
end;
3: begin
closegraph;
clrscr;
setcolor(lightred);
gotoxy(35,3);
writeln('You lose!!');
gotoxy(35,4);
writeln(score);
readln;
halt;
end;
end;
end;
end;
{-----------------------------------------------}
procedure net;
begin
for i:= 1 to 10 do
if ((x=minexe[i]) and ( y=mineye[i]-1)) or ((x=minexe[i]-2) and ( y=mineye[i]-1)) then begin
redestroy;
end;
end;
{-----------------------------------------------}
procedure show_man;
begin
textcolor(yellow);
gotoxy(x, y+0); write(' O');
gotoxy(x, y+1); write('XXX');
gotoxy(x, y+2); write(' X');
gotoxy(x, y+3); write('X X');
end;
{-----------------------------------------------}
procedure fill;
begin
randomize;
for i:= 1 to 10 do begin
minexe[i]:=random(80);
mineye[i]:=random(24);
end;
end;
{-----------------------------------------------}
procedure boom;
begin
for i:=1 to 10 do begin
if (minexe[i]<>0) and (mineye[i]<>0) then begin
textcolor(red);
gotoxy(minexe[i], mineye[i]); write('@');
end;
end;
end;
{-----------------------------------------------}
procedure min;
begin
for i:= 1 to 10 do begin
if (x=minexe[i]) and ( y=mineye[i]-3)or ((x=minexe[i]-2) and ( y=mineye[i]-3)) then begin
clrscr;
textcolor(lightred);
gotoxy(35,3); writeln('You are dead!!!');
gotoxy(35,4); writeln('Your score was:', score);
textcolor(lightgray);
readkey; halt;
end;
end;
end;
begin
score:=0;
clrscr;
gotoxy(35,3); writeln('Choose level:');
gotoxy(35,4); writeln('1. Legko');
gotoxy(35,5); writeln('2. Slozno');
read(d);
case d of
1: d:=150;
2: d:=50;
end;
b := 0;
x :=5; y :=20;
fill;
show_man;
boom; min;
repeat
c:=readkey;
case c of
#13:begin
gotoxy(35,3); writeln('Your score is:', score);
readln;
end;
#32: net;
#0:
case readkey of
left : dec(x);
right: inc(x);
up : dec(y);
down : inc(y);
end;
end;
clrscr;
show_man;
boom; min;
b:=b+1;
if score= 10 then begin
b:=d;
clrscr;
gotoxy(35,3);
textcolor(White);
writeln('You win the game!!!');
readkey;
end;
until b=d;
readkey;
end.