0 bình luận về “viết chương trình làm trò chơi plappy bird”
USES crt; VAR x,y,i,k,flr_x,flr_y,can_jump:BYTE; a:ARRAY[1..80,1..25] OF STRING; mov:CHAR; BEGIN REPEAT textcolor(10); writeln; writeln(‘THIS IS AN EXAMPLE OF THE GAME WITH GRAVITY’); textcolor(13); write(‘Press ‘,#27,’ and ‘,#26,’ to move ‘); textcolor(11); write(#15); textcolor(13); write(‘, X to jump (Press, do not hold it). Reach ‘); textcolor(14); write(#30); textcolor(13); writeln(‘ to win.’); write(‘If you touch ‘); textcolor(12); write(#173); textcolor(13); write(‘, you will lose.’); textcolor(11); x:=10; y:=6; a[x,y]:=#15; gotoxy(x,y); write(#15); textcolor(7); REPEAT flr_x:=random(80)+1; flr_y:=random(18)+6; i:=i+1; a[flr_x,flr_y]:=#219; gotoxy(flr_x,flr_y); write(#219); UNTIL i=100; FOR i:=1 TO 80 DO BEGIN a[i,5]:=#219; gotoxy(i,5); write(#219); END; a[80,21]:=#30; gotoxy(80,21); textcolor(14); write(#30); textcolor(12); FOR i:=1 TO 80 DO BEGIN gotoxy(i,24); write(#173); END; REPEAT IF keypressed THEN mov:=readkey; a[x,y]:=’ ‘; gotoxy(x,y); write(‘ ‘); IF mov=’x’ THEN IF a[x,y+1]=#219 THEN can_jump:=6; IF can_jump>0 THEN BEGIN can_jump:=can_jump-1; IF a[x,y-1]<>#219 THEN y:=y-1 ELSE can_jump:=0; END ELSE IF a[x,y+1]<>#219 THEN y:=y+1; IF mov=#77 THEN IF a[x+1,y]<>#219 THEN x:=x+1; IF mov=#75 THEN IF a[x-1,y]<>#219 THEN x:=x-1; a[x,y]:=#15; gotoxy(x,y); textcolor(11); write(#15); delay(80); mov:=’ ‘; UNTIL (a[x+1,y]=#30) OR (a[x,y+1]=#30) OR (a[x-1,y]=#30) OR (a[x,y-1]=#30) OR (y=23); window(30,10,50,20); IF y<>23 THEN BEGIN textcolor(10); writeln(‘You WIN!’); END ELSE BEGIN textcolor(15); writeln(‘You LOSE!’); END; writeln; textcolor(13); write(‘Again? (Y/N)’); REPEAT mov:=readkey; UNTIL (upcase(mov)=’Y’) OR (upcase(mov)=’N’); IF upcase(mov)=’Y’ THEN BEGIN window(1,1,80,25); clrscr; FOR i:=1 TO 80 DO FOR k:=1 TO 25 DO a[i,k]:=’ ‘; i:=0; END; UNTIL upcase(mov)=’N’ END.
uses crt,KEY; var h1,h2,h3,h4,banh1,banh2,can1,can2,chay1,chay2,i : integer; diem,mang,gach1,gach2,phim,chon,dokho,muiten:integer; chondokho : integer; label thoat; procedure banh; begin CLRSCR; for i:=20 to 62 do begin gotoxy(i,7); write(‘__’); end; for i:=8 to 20 do begin gotoxy(20,i); write(‘|’); end; for i:=20 to 62 do begin gotoxy(i,20); write(‘__’); {IN giao dien game} end; for i:=8 to 20 do begin gotoxy(62,i); write(‘|’); end; gotoxy(30,8); Write(‘BOUNCING BALL I’); GOTOXY(25,11); write(‘CHAO MUNG DEN VOI GAME BOUNCING BALL’); GOTOXY(25,13); WRITE(‘DUNG PHIM “<-” DE DI CHUYEN SANG TRAI’); GOTOXY(25,14); WRITE(‘DUNG PHIM “->” DE DI CHUYEN SANG PHAI’); gotoxy(25,15); write(‘DUNG PHIM “ESC” DE THOAT [ QUIT ] ‘); GOTOXY(25,17); WRITE(‘NHAN ENTER DE BAT DAU CHOI !’); GOTOXY(25,19); WRITE(‘–> ENTER !’); GOTOXY(25,23); write(‘WRITE BY HACK258147’);
READLN; clrscr; diem:=0; banh1:=40 ; banh2:=18; {toa do cua banh} gotoxy(banh1,banh2); write(‘o’); {in banh} { Phan Choi game } h2:=7; for h1:=3 to 19 do begin gotoxy(h2,h1); write(‘//’); end; h4:=67; for h3:=3 to 19 do begin gotoxy(h4,h3); write(‘//’); end; for h2:=7 to 67 do begin gotoxy(h2,2); write(‘//’); end; for h2:=7 to 67 do begin gotoxy(h2,20); write(‘//’); end; gotoxy(70,3); write(‘BOUNCING’); GOTOXY(70,4); WRITE(‘BALL I’); FOR i:=5 to 20 do begin gotoxy(70,i); write(‘/////////’); end; {phan tao gach} for i:=12 to 62 do begin gotoxy(i,3); write(”); end; for i:=12 to 62 do begin gotoxy(i,4); write(”); end; for i:=12 to 62 do begin gotoxy(i,5); write(”); end; for i:=12 to 62 do begin gotoxy(i,6); write(”); end;
end; procedure chaybanh; label top,thoat,tiep,tiep2,chinhdokho,dieukhien; begin can1:=39; can2:=19; {39,19} gotoxy(30,24); write(‘ESC : Thoat game’); gotoxy(50,24); write(‘Write By hack258147’); gotoxy(50,25); write(‘diendantoanhoc.net’);
if (dokho=upkey) and (muiten=13) then goto chinhdokho; if (dokho=upkey) then begin gotoxy(10,muiten); write(‘ ‘); muiten:=muiten-1; gotoxy(10,muiten); write(‘–>’); end; if (dokho=dnkey) and (muiten=15) then goto chinhdokho; if (dokho=dnkey) then begin gotoxy(10,muiten); write(‘ ‘); muiten:=muiten+1; gotoxy(10,muiten);write(‘–>’); end; chondokho:=getkey; if chondokho=enterkey then begin gotoxy(10,12); write(‘ ‘); gotoxy(14,13); write(‘ ‘); gotoxy(14,14); write(‘ ‘); gotoxy(14,15); write(‘ ‘); gotoxy(10,muiten); write(‘ ‘); end; until (chondokho=enterkey); tiep: repeat if muiten=13 then delay(50000); if muiten=14 then delay(40000); if muiten=15 then delay(30000); gotoxy(banh1,banh2); {CT chay Banh} write(‘ ‘); banh1:=banh1+chay1; banh2:=banh2+chay2; gotoxy(banh1,banh2); write(‘o’); gotoxy(can1,can2); write(‘MMMM’);
if keypressed then begin dieukhien: phim:=Getkey;
tiep2: {39:19 toa do cua can} if phim=leftkey then begin gotoxy(can1,can2); write(‘ ‘); {dieu khien can qua trai} can1:=can1-3; if (can1=9) and (can2=19) then can1:=can1+3; gotoxy(can1,can2); write(‘MMMM’); end;
if phim=rightkey then begin gotoxy(can1,can2); write(‘ ‘); {dieu khien can qua phai} can1:=can1+3; if (can1=66) and (can2=19) then can1:=can1-3; gotoxy(can1,can2); write(‘MMMM’); end; end;
if phim=inskey then begin mang:=9999; gotoxy(5,25); write(‘ ‘); {hack mang} gotoxy(5,25); write(‘Mang : ‘,mang); end; if phim=homekey then begin diem:=9999; gotoxy(5,24); write(‘ ‘); {hack diem} gotoxy(5,24); write(‘Diem : ‘,diem); end;
if (can1=banh1) and (can2=banh2) then begin diem:=diem+1; gotoxy(5,24); write(‘ ‘); gotoxy(5,24); write(‘Diem : ‘,diem); gotoxy(can1,can2); write(‘M’); chay1:=random(3); if chay1 = 1 then chay1:=+1; if chay1 = 2 then chay1:=-1; if chay1 = 3 then chay1:=+1; if chay1 = 0 then chay1:=-1; {banh trung can_1} chay2:=-1; gotoxy(can1,can2); write(‘M’); end;
if (can1+1=banh1) and (can2=banh2) then begin diem:=diem+1; gotoxy(5,24); write(‘ ‘); gotoxy(5,24); write(‘Diem : ‘,diem); gotoxy(can1+1,can2); write(‘M’); chay1:=random(3); if chay1 = 1 then chay1:=+1; if chay1 = 2 then chay1:=-1; if chay1 = 3 then chay1:=+1; if chay1 = 0 then chay1:=-1; {banh trung can 2} chay2:=-1; gotoxy(can1+1,can2); write(‘M’); end; if (can1+2=banh1) and (can2=banh2) then begin diem:=diem+1; gotoxy(5,24); write(‘ ‘); gotoxy(5,24); write(‘Diem : ‘,diem); gotoxy(can1,can2); write(‘M’);
chay1:=random(3); if chay1 = 1 then chay1:=+1; if chay1 = 2 then chay1:=-1; if chay1 = 3 then chay1:=+1; if chay1 = 0 then chay1:=-1; {banh trung can 3} chay2:=-1; gotoxy(can1+2,can2); write(‘M’); end; if (can1+3=banh1) and (can2=banh2) then begin diem:=diem+1; gotoxy(5,24); write(‘ ‘); gotoxy(5,24); write(‘Diem : ‘,diem); gotoxy(can1+3,can2); write(‘M’); chay1:=random(3); if chay1 = 1 then chay1:=+1; if chay1 = 2 then chay1:=-1; if chay1 = 3 then chay1:=+1; if chay1 = 0 then chay1:=-1;
{banh trung can 4} chay2:=-1; gotoxy(can1+3,can2); write(‘M’); end; { 9:2/ toa do ban dau cua banh } for i:=8 to 66 do begin
if (banh1=i) and (banh2=3) then begin {neu banh dung tuong tren} chay1:=random(3) ; if chay1 = 1 then chay1:=+1; if chay1 = 2 then chay1:=-1; if chay1 = 3 then chay1:=+1; if chay1 = 0 then chay1:=-1; chay2:=+1; end; {66:3} end;
for i:=4 to 20 do begin
if (banh2=i) and (banh1=10) then begin {neu banh dung tuong trai} chay1:=+1; randomize; chay2:=random(3); if chay2 = 1 then chay2:=+1; if chay2 = 2 then chay2:=-1; if chay2 = 3 then chay2:=+1; if chay2 = 0 then chay2:=-1; end; end; {9:3:19} for i:=4 to 19 do begin
if (banh2=i) and (banh1=66) then begin chay1:=-1; randomize; chay2:=random(3); {neu banh dung tuong phai} if chay2 = 1 then chay2:=+1; if chay2 = 2 then chay2:=-1; if chay2 = 3 then chay2:=+1; if chay2 = 0 then chay2:=-1;end; end; for i:=9 to 66 do begin if (banh1<>can1) and (banh1<>can1+1) and (banh1<>can1+2) and (banh1<>can1+3) then begin if (banh2=19) and (banh1=i) then begin delay(60000); delay(60000); mang:=mang-1; {neu banh dung day} gotoxy(10,12); write(‘Ban bi mat mot mang/ bam ENTER de choi tiep ‘); gotoxy(10,13); write(‘Nhan ESC de thoat ‘); chon:=Getkey; gotoxy(10,12); write(‘ ‘); gotoxy(10,13); write(‘ ‘); gotoxy(5,25); write(‘ ‘); gotoxy(5,25); write(‘Mang : ‘,mang); gotoxy(5,24); write(‘ ‘); gotoxy(5,24); write(‘Diem : ‘,diem); if chon=enterkey then goto top; if chon=Esckey then exit; if chon=rightkey then goto top; if chon=leftkey then goto top; if chon=upkey then goto top; if chon=dnkey then goto top; end; end; end;
if mang = -1 then begin gotoxy(10,12); write(‘GAME OVER/Nhan Esc de thoat , nhan Space de choi tiep’); gotoxy(10,13); write(‘Diem cua ban : ‘,diem); chon:=getkey; gotoxy(10,12); write(‘ ‘); gotoxy(10,13); write(‘ ‘); if chon=esckey then exit; if chon=spacekey then begin mang:=3; diem:=0; gotoxy(5,25); write(‘ ‘); {diem :24,5 / mang:25,5} gotoxy(5,25); write(‘Mang : ‘,mang); gotoxy(5,24); write(‘Diem : ‘,diem); goto top; end; end; until (phim=esckey); end;
USES crt;
VAR x,y,i,k,flr_x,flr_y,can_jump:BYTE;
a:ARRAY[1..80,1..25] OF STRING;
mov:CHAR;
BEGIN
REPEAT
textcolor(10); writeln; writeln(‘THIS IS AN EXAMPLE OF THE GAME WITH GRAVITY’);
textcolor(13); write(‘Press ‘,#27,’ and ‘,#26,’ to move ‘); textcolor(11); write(#15);
textcolor(13); write(‘, X to jump (Press, do not hold it). Reach ‘);
textcolor(14); write(#30); textcolor(13); writeln(‘ to win.’);
write(‘If you touch ‘); textcolor(12); write(#173); textcolor(13); write(‘, you will lose.’);
textcolor(11); x:=10; y:=6; a[x,y]:=#15; gotoxy(x,y); write(#15); textcolor(7);
REPEAT
flr_x:=random(80)+1; flr_y:=random(18)+6; i:=i+1; a[flr_x,flr_y]:=#219; gotoxy(flr_x,flr_y); write(#219);
UNTIL i=100;
FOR i:=1 TO 80 DO BEGIN a[i,5]:=#219; gotoxy(i,5); write(#219); END;
a[80,21]:=#30; gotoxy(80,21); textcolor(14); write(#30);
textcolor(12); FOR i:=1 TO 80 DO BEGIN gotoxy(i,24); write(#173); END;
REPEAT
IF keypressed THEN mov:=readkey; a[x,y]:=’ ‘; gotoxy(x,y); write(‘ ‘);
IF mov=’x’ THEN IF a[x,y+1]=#219 THEN can_jump:=6;
IF can_jump>0 THEN BEGIN
can_jump:=can_jump-1; IF a[x,y-1]<>#219 THEN y:=y-1 ELSE can_jump:=0;
END ELSE IF a[x,y+1]<>#219 THEN y:=y+1;
IF mov=#77 THEN IF a[x+1,y]<>#219 THEN x:=x+1;
IF mov=#75 THEN IF a[x-1,y]<>#219 THEN x:=x-1;
a[x,y]:=#15; gotoxy(x,y); textcolor(11); write(#15); delay(80); mov:=’ ‘;
UNTIL (a[x+1,y]=#30) OR (a[x,y+1]=#30) OR (a[x-1,y]=#30) OR (a[x,y-1]=#30) OR (y=23);
window(30,10,50,20);
IF y<>23 THEN BEGIN textcolor(10); writeln(‘You WIN!’); END
ELSE BEGIN textcolor(15); writeln(‘You LOSE!’); END;
writeln; textcolor(13); write(‘Again? (Y/N)’);
REPEAT mov:=readkey; UNTIL (upcase(mov)=’Y’) OR (upcase(mov)=’N’);
IF upcase(mov)=’Y’ THEN BEGIN
window(1,1,80,25); clrscr; FOR i:=1 TO 80 DO FOR k:=1 TO 25 DO a[i,k]:=’ ‘; i:=0;
END;
UNTIL upcase(mov)=’N’
END.
uses crt,KEY;
var h1,h2,h3,h4,banh1,banh2,can1,can2,chay1,chay2,i : integer;
diem,mang,gach1,gach2,phim,chon,dokho,muiten:integer;
chondokho : integer;
label thoat;
procedure banh;
begin
CLRSCR;
for i:=20 to 62 do begin
gotoxy(i,7);
write(‘__’);
end;
for i:=8 to 20 do begin
gotoxy(20,i);
write(‘|’);
end;
for i:=20 to 62 do begin
gotoxy(i,20);
write(‘__’); {IN giao dien game}
end;
for i:=8 to 20 do begin
gotoxy(62,i);
write(‘|’);
end;
gotoxy(30,8);
Write(‘BOUNCING BALL I’);
GOTOXY(25,11);
write(‘CHAO MUNG DEN VOI GAME BOUNCING BALL’);
GOTOXY(25,13);
WRITE(‘DUNG PHIM “<-” DE DI CHUYEN SANG TRAI’);
GOTOXY(25,14);
WRITE(‘DUNG PHIM “->” DE DI CHUYEN SANG PHAI’);
gotoxy(25,15);
write(‘DUNG PHIM “ESC” DE THOAT [ QUIT ] ‘);
GOTOXY(25,17);
WRITE(‘NHAN ENTER DE BAT DAU CHOI !’);
GOTOXY(25,19);
WRITE(‘–> ENTER !’);
GOTOXY(25,23);
write(‘WRITE BY HACK258147’);
READLN;
clrscr;
diem:=0;
banh1:=40 ; banh2:=18; {toa do cua banh}
gotoxy(banh1,banh2);
write(‘o’); {in banh}
{ Phan Choi game }
h2:=7;
for h1:=3 to 19 do begin
gotoxy(h2,h1);
write(‘//’);
end;
h4:=67;
for h3:=3 to 19 do begin
gotoxy(h4,h3);
write(‘//’);
end;
for h2:=7 to 67 do begin
gotoxy(h2,2);
write(‘//’);
end;
for h2:=7 to 67 do begin
gotoxy(h2,20);
write(‘//’);
end;
gotoxy(70,3);
write(‘BOUNCING’);
GOTOXY(70,4);
WRITE(‘BALL I’);
FOR i:=5 to 20 do begin
gotoxy(70,i);
write(‘/////////’); end;
{phan tao gach}
for i:=12 to 62 do begin
gotoxy(i,3);
write(”);
end;
for i:=12 to 62 do begin
gotoxy(i,4);
write(”);
end;
for i:=12 to 62 do begin
gotoxy(i,5);
write(”);
end;
for i:=12 to 62 do begin
gotoxy(i,6);
write(”);
end;
end;
procedure chaybanh;
label top,thoat,tiep,tiep2,chinhdokho,dieukhien;
begin
can1:=39;
can2:=19; {39,19}
gotoxy(30,24);
write(‘ESC : Thoat game’);
gotoxy(50,24);
write(‘Write By hack258147’);
gotoxy(50,25);
write(‘diendantoanhoc.net’);
mang:=3;
top:
chay1:=0;
chay2:=-1;
gotoxy(5,25);
write(‘Mang : ‘,mang);
gotoxy(banh1,banh2);
write(‘ ‘);
banh1:=40;
banh2:=18;
gotoxy(5,24);
write(‘Diem : ‘,diem);
if chondokho=enterkey then goto tiep;
muiten:=13;
chinhdokho:
gotoxy(10,12);
write(‘Chon do kho’);
gotoxy(14,13);
write(‘De’);
gotoxy(14,14);
write(‘Binh thuong’);
gotoxy(14,15);
write(‘Kho’);
gotoxy(10,muiten);
write(‘–>’);
dokho:=getkey;
keypressed;
repeat
if (dokho=upkey) and (muiten=13) then goto chinhdokho;
if (dokho=upkey) then begin
gotoxy(10,muiten);
write(‘ ‘);
muiten:=muiten-1;
gotoxy(10,muiten);
write(‘–>’);
end;
if (dokho=dnkey) and (muiten=15) then goto chinhdokho;
if (dokho=dnkey) then begin
gotoxy(10,muiten);
write(‘ ‘);
muiten:=muiten+1;
gotoxy(10,muiten);write(‘–>’); end;
chondokho:=getkey;
if chondokho=enterkey then begin
gotoxy(10,12);
write(‘ ‘);
gotoxy(14,13);
write(‘ ‘);
gotoxy(14,14);
write(‘ ‘);
gotoxy(14,15);
write(‘ ‘);
gotoxy(10,muiten);
write(‘ ‘);
end;
until (chondokho=enterkey);
tiep:
repeat
if muiten=13 then delay(50000);
if muiten=14 then delay(40000);
if muiten=15 then delay(30000);
gotoxy(banh1,banh2); {CT chay Banh}
write(‘ ‘);
banh1:=banh1+chay1;
banh2:=banh2+chay2;
gotoxy(banh1,banh2);
write(‘o’);
gotoxy(can1,can2);
write(‘MMMM’);
if keypressed then begin
dieukhien:
phim:=Getkey;
tiep2: {39:19 toa do cua can}
if phim=leftkey then begin
gotoxy(can1,can2);
write(‘ ‘); {dieu khien can qua trai}
can1:=can1-3;
if (can1=9) and (can2=19) then can1:=can1+3;
gotoxy(can1,can2);
write(‘MMMM’);
end;
if phim=rightkey then begin
gotoxy(can1,can2);
write(‘ ‘); {dieu khien can qua phai}
can1:=can1+3;
if (can1=66) and (can2=19) then can1:=can1-3;
gotoxy(can1,can2);
write(‘MMMM’);
end;
end;
if phim=inskey then begin
mang:=9999;
gotoxy(5,25);
write(‘ ‘); {hack mang}
gotoxy(5,25);
write(‘Mang : ‘,mang);
end;
if phim=homekey then begin
diem:=9999;
gotoxy(5,24);
write(‘ ‘); {hack diem}
gotoxy(5,24);
write(‘Diem : ‘,diem);
end;
if (can1=banh1) and (can2=banh2) then begin
diem:=diem+1;
gotoxy(5,24);
write(‘ ‘);
gotoxy(5,24);
write(‘Diem : ‘,diem);
gotoxy(can1,can2);
write(‘M’);
chay1:=random(3);
if chay1 = 1 then chay1:=+1;
if chay1 = 2 then chay1:=-1;
if chay1 = 3 then chay1:=+1;
if chay1 = 0 then chay1:=-1; {banh trung can_1}
chay2:=-1;
gotoxy(can1,can2);
write(‘M’);
end;
if (can1+1=banh1) and (can2=banh2) then begin
diem:=diem+1;
gotoxy(5,24);
write(‘ ‘);
gotoxy(5,24);
write(‘Diem : ‘,diem);
gotoxy(can1+1,can2);
write(‘M’);
chay1:=random(3);
if chay1 = 1 then chay1:=+1;
if chay1 = 2 then chay1:=-1;
if chay1 = 3 then chay1:=+1;
if chay1 = 0 then chay1:=-1;
{banh trung can 2}
chay2:=-1;
gotoxy(can1+1,can2);
write(‘M’);
end;
if (can1+2=banh1) and (can2=banh2) then begin
diem:=diem+1;
gotoxy(5,24);
write(‘ ‘);
gotoxy(5,24);
write(‘Diem : ‘,diem);
gotoxy(can1,can2);
write(‘M’);
chay1:=random(3);
if chay1 = 1 then chay1:=+1;
if chay1 = 2 then chay1:=-1;
if chay1 = 3 then chay1:=+1;
if chay1 = 0 then chay1:=-1; {banh trung can 3}
chay2:=-1;
gotoxy(can1+2,can2);
write(‘M’);
end;
if (can1+3=banh1) and (can2=banh2) then begin
diem:=diem+1;
gotoxy(5,24);
write(‘ ‘);
gotoxy(5,24);
write(‘Diem : ‘,diem);
gotoxy(can1+3,can2);
write(‘M’);
chay1:=random(3);
if chay1 = 1 then chay1:=+1;
if chay1 = 2 then chay1:=-1;
if chay1 = 3 then chay1:=+1;
if chay1 = 0 then chay1:=-1;
{banh trung can 4}
chay2:=-1;
gotoxy(can1+3,can2);
write(‘M’);
end;
{ 9:2/ toa do ban dau cua banh }
for i:=8 to 66 do begin
if (banh1=i) and (banh2=3) then begin {neu banh dung tuong tren}
chay1:=random(3) ;
if chay1 = 1 then chay1:=+1;
if chay1 = 2 then chay1:=-1;
if chay1 = 3 then chay1:=+1;
if chay1 = 0 then chay1:=-1;
chay2:=+1; end; {66:3}
end;
for i:=4 to 20 do begin
if (banh2=i) and (banh1=10) then begin {neu banh dung tuong trai}
chay1:=+1;
randomize;
chay2:=random(3);
if chay2 = 1 then chay2:=+1;
if chay2 = 2 then chay2:=-1;
if chay2 = 3 then chay2:=+1;
if chay2 = 0 then chay2:=-1; end;
end; {9:3:19}
for i:=4 to 19 do begin
if (banh2=i) and (banh1=66) then begin
chay1:=-1;
randomize;
chay2:=random(3); {neu banh dung tuong phai}
if chay2 = 1 then chay2:=+1;
if chay2 = 2 then chay2:=-1;
if chay2 = 3 then chay2:=+1;
if chay2 = 0 then chay2:=-1;end;
end;
for i:=9 to 66 do begin
if (banh1<>can1) and (banh1<>can1+1) and (banh1<>can1+2) and (banh1<>can1+3) then begin
if (banh2=19) and (banh1=i) then begin
delay(60000);
delay(60000);
mang:=mang-1; {neu banh dung day}
gotoxy(10,12);
write(‘Ban bi mat mot mang/ bam ENTER de choi tiep ‘);
gotoxy(10,13);
write(‘Nhan ESC de thoat ‘);
chon:=Getkey;
gotoxy(10,12);
write(‘ ‘);
gotoxy(10,13);
write(‘ ‘);
gotoxy(5,25);
write(‘ ‘);
gotoxy(5,25);
write(‘Mang : ‘,mang);
gotoxy(5,24);
write(‘ ‘);
gotoxy(5,24);
write(‘Diem : ‘,diem);
if chon=enterkey then goto top;
if chon=Esckey then exit;
if chon=rightkey then goto top;
if chon=leftkey then goto top;
if chon=upkey then goto top;
if chon=dnkey then goto top;
end;
end;
end;
if mang = -1 then begin
gotoxy(10,12);
write(‘GAME OVER/Nhan Esc de thoat , nhan Space de choi tiep’);
gotoxy(10,13);
write(‘Diem cua ban : ‘,diem);
chon:=getkey;
gotoxy(10,12);
write(‘ ‘);
gotoxy(10,13);
write(‘ ‘);
if chon=esckey then exit;
if chon=spacekey then begin
mang:=3;
diem:=0;
gotoxy(5,25);
write(‘ ‘); {diem :24,5 / mang:25,5}
gotoxy(5,25);
write(‘Mang : ‘,mang);
gotoxy(5,24);
write(‘Diem : ‘,diem);
goto top;
end;
end;
until (phim=esckey);
end;
begin
banh;
can1:=39; { CT chinh }
can2:=19;
gotoxy(can1,can2); {in can}
write(‘MMMM’);
chaybanh;
clrscr;
gotoxy(20,5);
write(‘GAME OVER /nhan Enter de thoat’);
gotoxy(20,6);
write(‘Diem cua ban : ‘,diem);
readln;
end.