Trò này mình viết lúc học lớp 11, mang lên trường cho mấy đứa bạn chơi. Giờ nghĩ lại thấy vui nên Post lên ai có hứng thú thì down về xài.
Còn đây là link Down: http://www.mediafire.com/?nmttyz2o5my
Code đây:
uses crt;
var a:char;
mx,my,i,d:byte;
hx,hy:integer;
score:integer;
x,y:array[1..104] of byte;
l:word;
const lbox=10; rbox=70;
tbox=5; bbox=45;
maxl=200;
Procedure DrawBox;
var i : byte;
Begin
Textcolor(White);
For i:=lbox-1 to rbox+1 do
begin Gotoxy(i,tbox-1); write('x');
Gotoxy(i,bbox+1); write('x');end;
For i:=tbox-1 to bbox+1 do
begin Gotoxy(lbox-1,i); write('x');
Gotoxy(rbox+1,i); write('x');end;
end;
procedure win;
begin
clrscr;
textmode(150);
gotoxy(25,13);
textcolor(20);
write('You are a Master with 70 point');
readln;
halt;
end;
procedure e;
var i : byte;
t,b,l,r : byte;
Begin
Textcolor(lightred);
GotoXY(x[1],y[1]); Write('@'); Delay(500);
GotoXY(x[1]-1,y[1]); Write('@');
GotoXY(x[1]+1,y[1]); Write('@');
GotoXY(x[1],y[1]-1); Write('@');
GotoXY(x[1],y[1]+1); Write('@');
Delay(500);
t := tbox; r := rbox;
b := bbox; l := lbox;
Textcolor(LightGray);
repeat;
For i:=l to r do
begin Gotoxy(i,t); write(':'); delay(1); end;
For i:=t to b do
begin Gotoxy(r,i); write(':'); delay(1); end;
For i:=r downto l+1 do
begin Gotoxy(i,b); write(':'); delay(1); end;
For i:=b downto t+1 do
begin Gotoxy(l,i); write(':'); delay(1); end;
if l<r then l:=l+1; if t<b then t:=t+1; if b>t then b:=b-1; if r>l then r:=r-1;
Until (l=r) and (t=b);
t := tbox; r := rbox;
b := bbox; l := lbox;
repeat;
For i:=l to r do
begin Gotoxy(i,t); write(' '); delay(1); end;
For i:=t to b do
begin Gotoxy(r,i); write(' '); delay(1); end;
For i:=r downto l+1 do
begin Gotoxy(i,b); write(' '); delay(1); end;
For i:=b downto t+1 do
begin Gotoxy(l,i); write(' '); delay(1); end;
if l<r then l:=l+1; if t<b then t:=t+1; if b>t then b:=b-1; if r>l then r:=r-1;
Until (l=r) and (t=b);
gotoxy(34,24);
textcolor(LightRed);
write('GAME OVER');
gotoxy(30,1);
textcolor(LightGreen);
write('You ate ',d-3,' apples');
gotoxy(30,2);
write('You got ',score,' scores');
readln;
halt;
end;
begin
randomize;
d:=3;
hx:=1;
mx:=random(rbox-lbox+1)+lbox;
my:=random(bbox-tbox+1)+tbox;
x[1]:=40;
y[1]:=25;
textmode(1000);
repeat
textcolor(15);
score:=0;
clrscr;
write('Choose Level (1..10) : ');readln(l);
until l in[1..10];
l:= maxl div l;
textcolor(0);
clrscr;
repeat
repeat
textcolor(8);
gotoxy(lbox-1,1); write('Developed by Augustine Bui');
textcolor(Yellow);
gotoxy(rbox-12,1); write('Apples : ',(d-3):5);
Gotoxy(lbox-1,2); write('Speed : ',maxl-l);
gotoxy(rbox-6-6,2);write('Scores : ',score:5);
gotoxy(mx,my); textcolor(14);write('*');
DrawBox;
for i:= d+1 downto 2 do
begin
x[i]:=x[i-1];
y[i]:=y[i-1];
end;
x[1]:=x[1]+hx;
y[1]:=y[1]+hy;
if (x[1]>rbox)or(x[1]<lbox)or(y[1]>bbox)or(y[1]<tbox) then e;
For i:= d+1 downto 2 do
if (y[1]=y) and (x[1]=x) then e;
gotoxy(x[d+1],y[d+1]);textcolor(0); write(' '); (* Xoa Node duoi *)
if (y[1]=my) and (x[1]=mx) then
begin
d:=d+1;
sound(1000);
delay(75);
nosound;
l:=l-2;
gotoxy(x[1],y[1]);
textcolor(LightGreen);
write(#1); (* Ve Them 1 node dau *)
score:=score + ((maxl-l)*10)div 10;
mx:=random(rbox-lbox+1)+lbox;
my:=random(bbox-tbox+1)+tbox;
end;
if d=78 then win;
textcolor(LightGreen);
gotoxy(x[1],y[1]);
write('@');
gotoxy(x[2],y[2]);
write('c');
textcolor(0);
Gotoxy(1,1);
delay(l);
until keypressed;
a:=readkey; if a= #0 then a:= readkey;
case a of
#75: if hx=0 then begin hx:=-1; hy:=0; end;
#77: if hx=0 then begin hx:=1; hy:=0; end;
#72: if hy=0 then begin hx:=0; hy:=-1; end;
#80: if hy=0 then begin hx:=0; hy:=1; end;
'd': d:=d+1;
end;
until a =#27;
0 nhận xét:
Đăng nhận xét