|
uses crt;
type
classifica=record
nome:string;
punteggio:integer;
end;
procedure cursoroff;
assembler;
asm
mov ah,1
mov ch,20h
int 10h
end;
procedure cursoron;
assembler;
asm
mov ah,1
mov ch,6
mov cl,7
int 10h
end;
function chrfind(x,y:byte):char;
var indirizzo: word;
depo : char;
begin
indirizzo:=(x-1)*2+(y-1)*160;
asm
push es
push di
mov ax,0B800H
mov es,ax
mov di,indirizzo
mov al,es:[di]
mov depo,al
pop es
pop di
end;
chrfind:=depo;
end;
type
opzioni=(New_game,Highscore,exit);
function menu(x,y,z,w:byte):opzioni;
var a,b:byte;
c:char;
begin
for a:=1 to 3*w do
begin
gotoxy(x,y+a-1);
for b:=1 to z do
write('Û');
end;
gotoxy(x,y+w);
for a:=1 to z do
write('Ü');
gotoxy(x,y+2*w);
for a:=1 to z do
write('Ü');
x:=x+z div 2 -4;
y:=y+w div 2;
textcolor(12);
gotoxy(x,y);
write('New game');
gotoxy(x,y+w);
write('Highscore');
gotoxy(x+2,y+2*w);
write('Exit');
a:=1;
textbackground(10);
repeat
case a of
1: begin
gotoxy(x,y);
write('New_game');
end;
2: begin
gotoxy(x,y+w);
write('Highscore');
end;
3: begin
gotoxy(x+2,y+2*w);
write('Exit');
end;
end;
textbackground(1);
c:=readkey;
if (c=#50) or (c=#56) then
case a of
1: begin
gotoxy(x,y);
write('New_game');
end;
2: begin
gotoxy(x,y+w);
write('Highscore');
end;
3: begin
gotoxy(x+2,y+2*w);
write('Exit');
end;
end;
if c=#50 then
if a<3 then
a:=a+1
else
a:=1;
if c=#56 then
if a>1 then
a:=a-1
else
a:=3;
textbackground(10);
until c=#13;
case a of
1: menu:=new_game;
2: menu:=highscore;
3: menu:=exit;
end;
end;
procedure sfondo(x,y,z,w:byte);
var i:integer;
begin
textbackground(x);
for i:=1 to 2000 do
write(' ');
gotoxy(1,1);
textbackground(y);
for i:=1 to 80 do
write(' ');
gotoxy(1,1);
textcolor(z);
write('Punteggio: 0');
gotoxy(60,1);
write('vite: ');
textbackground(x);
textcolor(w);
end;
var
x,y,u,v : array[1..100] of byte;
i,b,g,d : byte;
c : char;
morto,s : boolean;
vite : byte;
scelta : opzioni;
high : file of classifica;
p,h : integer;
classif : classifica;
t : string;
begin
assign(high,'highsc~1.dat');
clrscr;
cursoroff;
vite:=3;
repeat
scelta:=menu(15,5,60,3);
if scelta=exit then
halt;
if scelta=highscore then
begin
reset(high);
{$I+}
read(high,classif);
{$I-}
if ioresult<>0 then
write('Non ci sono punteggi salvati')
else
begin
clrscr;
write('Il miglior punteggio finora Š ',classif.punteggio,' di ',classif.nome);
end;
close(high);
end;
until scelta<>highscore;
sfondo(1,3,12,14);
repeat
for b:=1 to i do
begin
gotoxy(x[b],y[b]);
write(' ');
end;
if morto=true then
begin
s:=true;
vite:=vite-1;
gotoxy(u[d],v[d]);
write(' ');
end;
gotoxy(67,1);
textbackground(3);
textcolor(12);
write(vite);
textbackground(1);
textcolor(14);
morto:=false;
i:=4;
g:=i;
gotoxy(2,3);
for b:=1 to i do
write('Û');
b:=0;
repeat
b:=b+1;
g:=g-1;
x[b]:=2+g;
y[b]:=3;
until g=0;
u[1]:=1;
v[1]:=1;
d:=1;
repeat
if chrfind(u[d],v[d])<>'' then
begin
if d=100 then
d:=1
else
d:=d+1;
randomize;
u[d]:=random(80)+1;
v[d]:=random(25)+2;
gotoxy(u[d],v[d]);
i:=i+1;
textcolor(12);
textbackground(3);
gotoxy(12,1);
if s=false then
begin
p:=p+100;
write(p-100);
end
else
s:=false;
textcolor(13);
textbackground(1);
gotoxy(u[d],v[d]);
write('');
textcolor(14);
end;
c:=readkey;
case c of
#50: repeat
g:=i;
gotoxy(x[g],y[g]);
write(' ');
repeat
if g=1 then
y[1]:=y[1]+1
else
begin
x[g]:=x[g-1];
y[g]:=y[g-1];
end;
gotoxy(x[g],y[g]);
write('Û');
g:=g-1;
until g=0;
delay(150);
if (y[1]=26) or (chrfind(x[1],y[1]+1)='Û') then
morto:=true;
until keypressed or morto=true;
#52: repeat
g:=i;
gotoxy(x[g],y[g]);
write(' ');
repeat
if g=1 then
x[1]:=x[1]-1
else
begin
x[g]:=x[g-1];
y[g]:=y[g-1];
end;
gotoxy(x[g],y[g]);
write('Û');
g:=g-1;
until g=0;
delay(150);
if (x[1]=0) or (chrfind(x[1]-1,y[1])='Û') then
morto:=true;
until keypressed or morto=true;
#54: repeat
g:=i;
gotoxy(x[g],y[g]);
write(' ');
repeat
if g=1 then
x[1]:=x[1]+1
else
begin
x[g]:=x[g-1];
y[g]:=y[g-1];
end;
gotoxy(x[g],y[g]);
write('Û');
g:=g-1;
until g=0;
delay(150);
if (x[1]=81) or (chrfind(x[1]+1,y[1])='Û') then
morto:=true;
until keypressed or morto=true;
#56: repeat
g:=i;
gotoxy(x[g],y[g]);
write(' ');
repeat
if g=1 then
y[1]:=y[1]-1
else
begin
x[g]:=x[g-1];
y[g]:=y[g-1];
end;
gotoxy(x[g],y[g]);
write('Û');
g:=g-1;
until g=0;
delay(150);
if (y[1]=1) or (chrfind(x[1],y[1]-1)='Û') then
morto:=true;
until keypressed or morto=true;
#13: begin
gotoxy(37,12);
write('Uscire?');
gotoxy(38,13);
write('S/N');
repeat
c:=readkey;
if (c='S') or (c='s') then
halt;
until (c='N') or (c='n');
gotoxy(37,12);
write(' ');
gotoxy(38,13);
write(' ');
for b:=1 to i do
begin
gotoxy(x[b],y[b]);
write('Û');
end;
end;
#27: halt;
end;
until morto=true;
until vite=0;
clrscr;
cursoron;
if p<classif.punteggio then
write('Mi dispiace ma il tuo punteggio non Š il pi— alto')
else
begin
writeln('WOW!!!! Punteggio pi— alto!!!');
rewrite(high);
classif.punteggio:=p;
writeln('Come ti chiami?');
readln(t);
classif.nome:=t;
write(high,classif);
end;
readln;
end.
|
|