感谢世外苏子恒同学提供
uses crt;
var
x,y,xd,yd,xb,yb:shortint;
k:char;
procedure intro;
begin
clrscr;
writeln;
writeln;
writeln;
writeln;
writeln;
writeln('Naughty ball-II':48);
writeln('--by suziheng':47);
writeln;
writeln;
writeln('Use A(left) and D(right) to controll the board"=========="':69);
writeln;
writeln;
writeln('If the ball falls down below the screen, GAMEOVER!':65);
writeln;
writeln;
writeln('Press CTRL+C to exit':50);
writeln;
writeln;
writeln('Press Enter to start':50);
readln;
end;
procedure gameover;
begin
clrscr;
writeln;
writeln;
writeln;
writeln;
writeln('GAME OVER':45);
writeln;
writeln;
writeln(' -------------');
writeln(' O < why didn',chr(39),'t |');
writeln(' | you lift |');
writeln(' | me up !!?? |');
writeln(' -------------');
delay(10000);
exit;
end;
begin
cursoroff;
intro;
xb:=1;
yb:=24;
xd:=1;
yd:=1;
x:=2;
y:=2;
while true do begin
clrscr;
x:=x+xd;
y:=y+yd;
gotoxy(x,y);
write('O');
if keypressed then begin
k:=readkey;
if (k='a') and (xb>10) then xb:=xb-10;
if (k='d') and (xb<60) then xb:=xb+10;
end;
gotoxy(xb,yb);
write('====================');
delay(100);
if (x=80) or (x=1) then xd:=-xd;
if y=1 then yd:=-yd;
if (y=yb) and ((x>=xb) and (x<=xb+19)) then begin
sound(1);
delay(50);
nosound;
yd:=-yd;
end;
if y=25 then break;
end;
gameover;
end.