Allora ragazzi, ho intenzione di creare Snake in Pascal, e sono arrivato fino a quì per il momento:
Codice:
program snake;
uses crt;
var v:array[1..80,1..20] of char;
c,x,y,i:byte;
s:char;
begin
clrscr;
c:=3;
for y:=1 to 20 do
for x:=1 to 80 do (*Inizializzazione della matrice*)
v[x,y]:=' ';
(*-----------------------------------------------*)
x:=5;y:=3;
v[x-2,y]:='*';v[x-1,y]:='*';v[x,y]:='*'; (*Serpentino*)
repeat
delay(200);
gotoxy(x,y);
x:=x+1;
v[x,y]:='*'; (*Il serpente va a destra*)
v[x-c,y]:=' ';
for i:=x-c to x do write(v[i,y])
until keypressed;
(*-----------------------------------------------*)
s:=readkey;
if s='4' then
begin
x:=x-c+1;
repeat
delay(200);
x:=x-1;
gotoxy(x+c,y);
v[x,y]:='*';
v[x+c,y]:=' ';
for i:=x to x+c do write(v[i,y])
until keypressed
end;
readln
end.