program Sphinx;
// INGOUFF Christian, 11/01/12 - Version 1.0
uses crt;
type
	matrix = array of array of integer;
	matstring = array of array of string;
	coord = array[1..2] of integer;
	array_coord = array[1..4] of coord;
	array_itg = array[1..4] of integer;
	array_bool = array[1..4] of boolean;

//
//					//	DESIGN MENU	//
//

procedure victoryScreen();
begin
  writeln('                       *******************************************************************************');
  writeln('                                |                   |                  |                     |        ');
  writeln('                       _________|________________.=""_;=.______________|_____________________|________');
  writeln('                       |                   |  ,-"_,=""     `"=.|                  |                   ');
  writeln('                       |___________________|__"=._o`"-._        `"=.______________|___________________');
  writeln('                                 |                `"=._o`"=._      _`"=._                     |       ');
  writeln('                        _________|_____________________:=._o "=._."_.-="""=.__________________|_______');
  writeln('                       |                   |    __.--" , ; `"=._o." ,-"""-._ ".   |                   ');
  writeln('                       |___________________|_._"  ,. .` ` `` ,  `"-._"-._   ". "__|___________________');
  writeln('                                 |           |o`"=._` , "` `; .". ,  "-._"-._; ;              |       ');
  writeln('                        _________|___________| ;`-.o`"=._; ." ` "`."\` . "-._ /_______________|_______');
  writeln('                       |                   | |o;    `"-.o`"=._``  "` " ,__.--o;   |                   ');
  writeln('                       |___________________|_| ;     (#) `-.o `"=.`_.--"_o.-; ;___|___________________');
  writeln('                       ____/______/______/___|o;._    "      `".o|o_.--"    ;o;____/______/______/____');
  writeln('                       /______/______/______/_"=._o--._        ; | ;        ; ;/______/______/______/_');
  writeln('                       ____/______/______/______/__"=._o--._   ;o|o;     _._;o;____/______/______/____');
  writeln('                       /______/______/______/______/____"=._o._; | ;_.--"o.--"_/______/______/______/_');
  writeln('                       ____/______/______/______/______/_____"=.o|o_.--""___/______/______/______/____');
  writeln('                       /______/______/______/______/______/______/______/______/______/______/______/_');
  writeln('                       *******************************************************************************');
end;

procedure titre ();
begin
   writeln('             SSSSSSSSSSSSSSS                   hhhhhhh               iiii                                       ');
   writeln('           SS:::::::::::::::S                  h:::::h              i::::i                                      ');
   writeln('          S:::::SSSSSS::::::S                  h:::::h               iiii                                       ');
   writeln('          S:::::S     SSSSSSS                  h:::::h                                                          ');
   writeln('          S:::::S           ppppp   ppppppppp   h::::h hhhhh       iiiiiiinnnn  nnnnnnnn    xxxxxxx      xxxxxxx');
   writeln('          S:::::S           p::::ppp:::::::::p  h::::hh:::::hhh    i:::::in:::nn::::::::nn   x:::::x    x:::::x ');
   writeln('           S::::SSSS        p:::::::::::::::::p h::::::::::::::hh   i::::in::::::::::::::nn   x:::::x  x:::::x  ');
   writeln('            SS::::::SSSSS   pp::::::ppppp::::::ph:::::::hhh::::::h  i::::inn:::::::::::::::n   x:::::xx:::::x   ');
   writeln('              SSS::::::::SS  p:::::p     p:::::ph::::::h   h::::::h i::::i  n:::::nnnn:::::n    x::::::::::x    ');
   writeln('                 SSSSSS::::S p:::::p     p:::::ph:::::h     h:::::h i::::i  n::::n    n::::n     x::::::::x     ');
   writeln('                      S:::::Sp:::::p     p:::::ph:::::h     h:::::h i::::i  n::::n    n::::n     x::::::::x     ');
   writeln('                      S:::::Sp:::::p    p::::::ph:::::h     h:::::h i::::i  n::::n    n::::n    x::::::::::x    ');
   writeln('          SSSSSSS     S:::::Sp:::::ppppp:::::::ph:::::h     h:::::hi::::::i n::::n    n::::n   x:::::xx:::::x   ');
   writeln('          S::::::SSSSSS:::::Sp::::::::::::::::p h:::::h     h:::::hi::::::i n::::n    n::::n  x:::::x  x:::::x  ');
   writeln('          S:::::::::::::::SS p::::::::::::::pp  h:::::h     h:::::hi::::::i n::::n    n::::n x:::::x    x:::::x ');
   writeln('           SSSSSSSSSSSSSSS   p::::::pppppppp    hhhhhhh     hhhhhhhiiiiiiii nnnnnn    nnnnnnxxxxxxx      xxxxxxx');
   writeln('                             p:::::p                                                                            ');
   writeln('                             p:::::p                                                                            ');
   writeln('                            p:::::::p                                                                           ');
   writeln('                            p:::::::p                                                                           ');
   writeln('                            p:::::::p                                                                           ');
   writeln('                            ppppppppp                                                                           ');
end;

procedure logo();
begin
   writeln('                         .sSSSSSSSs                          ___                         sSSSSSSSs.                       ');
   writeln('                         sSS=""^^^"s                       ."///".                       s"^^^""=SSs                      ');
   writeln('              /\       , /  \_\_\|_/_)                    /|<> <>!\                     (_/_|/_/_/  \ ,       /\          ');
   writeln('             /";;     /| \\\/.-. .-./                    /-|  ^  !-\                     \.-. .-.\/// |\     ;;"\         ');
   writeln('            / \;|    /. \,S"  -   - |                   /-- \_=_/ --\                    | -   -  "S,/ .\    |;/ \        ');
   writeln('           / -.;|    | ".SS     _|  ;                   )---| W |---(                    ;  |_     SS." |    |;.- \       ');
   writeln('          ; "-.;\,   |"-.SS\   __  /S                  /-\--| W |--/-\                   S\  __   /SS.-"|   ,/;.-" ;      ');
   writeln('          | _  ";\\.  \" SSS\_____/SS                 (_-_--|_-_|--___)                  SS\_____/SSS "/  .//;"  _ |      ');
   writeln('          |  "- ";\\.  \_SSS[_____]SS                (-___  -_-- _-- -_)                 SS[_____]SSS_/  .//;" -"  |      ');
   writeln('          \ "--.-";;-. __SSS/\    SSS                )-_ _--_ _ ___--__|                 SSS    /\SSS__ .-;;"-.--" /      ');
   writeln('           \  .--" ";;.=SSS`\\_\_SSS                 (___ --__  __ __--(                 SSS_/_//`SSS=.";;" "--.  /       ');
   writeln('            `._ .-"` _";;..=.=.=.\.=\               /-_  / __ -_ -__  \_\                /=./.=.=.=..;;"_ `"-. _.`        ');
   writeln('               ;-._-"  _.;\.=.=.=.|.=|             _>/  -- /|___| _ \ -_ )              |=.|.=.=.=./;._  "-_.-;           ');
   writeln('     ,     _.-"    `"=._  ;\=.=__/__/             /--  _ - _/   \>\ -  -- \              \__\__\=.=/;  _.="`   "-._     , ');
   writeln('     )\ ."`   __        ".;|.=.=.=./             ( / / /   >     \   \ \ \_)              \.=.=.=./;."        __   `". /( ');
   writeln('     (_\   .-`  ".   |    \/=.=.=/"              | |-" | |/       \| |   |_|               `\=.=.=\/    |   ."  `-.   /_) ');
   writeln('      /\\         \-,|     |.--"|                L_|_|_|_/         L_L_|_l_)                  |"--.|    |,-/         //\  ');
   writeln('     /  \`,       //  \    | |  |                                                             |  | |   /  \\       ,`/  \ ');
   writeln('    ( (__) )  _.-"--,  \   | |  "--,                                                       ,--"  | |  /  ,(("-._  ( (__) )');
   writeln('     ;----" -"--,__}}}  \  "--, __}}}                                                     {{{__ ,--" /  {{{__,--"- "----; ');
   writeln('     \_________}}}       \___}}}                                                               {{{___/       {{{________/ ');

end;

//
//					//	AFFICHAGE DE LA GRILLE		//
//

procedure convertGrille(grille : matrix ; var grilchar : matstring ; taille : coord);
// INGOUFF Christian, 11/01/12 - Version 1.0
// Convertit la grille (array of array of integer) en grilchar (array of array of char)
var
	i,j : integer;
begin
	setLength(grilchar,taille[1],taille[2]);
	for i := 0 to taille[1]-1 do
		for j := 0 to taille[2]-1 do
			case grille[i+1,j+1] of
				-42 : grilchar[i,j] := ' ▓▓▓ '; // Mur
				10 : grilchar[i,j] := '  o  '; // Porte d'entrée
				0 : grilchar[i,j] := '     '; // Vide
				-5, -1 : grilchar[i,j] := '  .  '; // Chemin
				15 : grilchar[i,j] := '  ▲  '; // Pions
				16 : grilchar[i,j] := '  ▼  ';
				17 : grilchar[i,j] := '  ◄  ';
				18 : grilchar[i,j] := '  ►  ';
				42 : grilchar[i,j] := '  X  '; // Trésor
			end;
end;
								

procedure affichGrille(grille : matrix ; taille : coord);
// INGOUFF Christian, 11/01/12 - Version 1.0
// Affiche la grille de jeu à l'écran
// Ini = TRUE dans le cadre de l'initialisation de la grille (chemin optimal), FALSE sinon.
var
	i, j : integer;
	grilchar : matstring;
begin
	convertgrille(grille,grilchar,taille);
	write('   .');
	for i := 1 to taille[1]-1 do
	begin
		if i < 10 then write('_');
		write('_',i,'___');
	end;
	if i < 10 then write('_');
	writeln('_',i+1,'__.');
	for j := 0 to taille[2]-1 do
	begin
		write('   ');
		for i := 0 to taille[1]-1 do
			write('|     ');
		writeln('|');
		if j < 9 then write(' ');
		write(' ',j+1);
		for i := 0 to taille[1]-1 do
			write('|',grilchar[i,j]);
		writeln('|');
		write('   ');
		for i := 0 to taille[1]-1 do
			write('|_____');
		writeln('|');
	end;
end;

//
//					//	VERIFICATION DE LA GRILLE	//
//

procedure arrayDirec(var direc : array_coord ; loc : coord);
// INGOUFF Christian, 15/01/12 - Version 1.0
// Retourne les coordonnées des cases environnantes (dans direc)
// (1,1),(1,2) : haut | (2,1),(2,2) : bas | (3,1),(3,2) : gauche | (4,1),(4,2) : droite
begin
	direc[1,1] := loc[1];
	direc[1,2] := loc[2]-1;
	
	direc[2,1] := loc[1];
	direc[2,2] := loc[2]+1;
	
	direc[3,1] := loc[1]-1;
	direc[3,2] := loc[2];
	
	direc[4,1] := loc[1]+1;
	direc[4,2] := loc[2];
end;

procedure extracGrille(var grille : matrix ; grilcoups : matrix ; loc : coord);
// INGOUFF Christian, 16/01/12
// Modélise le chemin obtenu avec algo Dijkstra. Part de trésor (case = nombre de coups) pour aller au départ (case = 0)
var
	direc : array_coord;
	i : integer;
begin
	arrayDirec(direc,loc);
	i := 1;
	if grille[loc[1],loc[2]] <> 10 then
		while i <= 4 do
			if grilcoups[direc[i,1],direc[i,2]] = grilcoups[loc[1],loc[2]] - 1 then
			begin
				grille[loc[1],loc[2]] := -1;
				extracGrille(grille,grilcoups,direc[i]);
				i := 5;
			end
			else
				i := i+1;
end;

procedure bornes(var inf, sup : coord ; enter, taille : coord ; dist : integer);
// Définit inf et sup dans le cadre de "dijkstra"
var
	i : integer;
begin
	for i := 1 to 2 do
	begin
		inf[i] := enter[i]-dist+1;
		if inf[i] < 1 then inf[i] := 1;
		sup[i] := enter[i]+dist+1;
		if sup[i] > taille[i] then sup[i] := taille[i];
	end;
end;

procedure dijkstra(grille : matrix ; var grilcoups : matrix ; tresor, enter, taille : coord ; var nb_coups : integer);
// INGOUFF Christian, 16/01/12
// Test algorithme de Dijkstra (Chemin le plus court optimal, mais assez lourd en opérations)
var
	i, j, k, dist : integer; // dist = Distance par rapport au départ
	loc, inf, sup : coord; // inf et sup = valeurs qui augmenteront selon la distance au départ (recherche en "cercle")
	direc : array_coord;
	valide : boolean;
begin
	dist := 0;
	valide := TRUE;
	while valide and (grilcoups[tresor[1],tresor[2]] = -1) do // Boucle jusqu'à trésor trouvé ou impossible de continuer
	begin
		valide := FALSE;
		bornes(inf,sup,enter,taille,dist);
		for i := inf[1]-1 to sup[1]-1 do
			for j := inf[2]-1 to sup[2]-1 do // On parcourt le tableau d'abord en cercle (avec inf et sup) puis en entier quand dist > taille
				if grilcoups[i,j] = dist then // Si la case correspond à ce tour (dist)
				begin
					loc[1] := i;
					loc[2] := j; // On assigne les coordonnées de cette case à "loc"
					arrayDirec(direc,loc); // On obtient les coordonnées des cases adjacentes
					for k := 1 to 4 do // Pour chaque case adjacente
						if grilcoups[direc[k,1],direc[k,2]] = -1 then // Si la case n'a pas été franchie
						begin
							grilcoups[direc[k,1],direc[k,2]] := dist+1; // La remplir pour le tour suivant (dist+1)
							valide := TRUE; // Indique qu'au moins une case a été remplie pendant ce tour
						end;
				end;
		dist := dist+1;
	end;
	if not valide then nb_coups := -1 // Grille non valide
	else nb_coups := dist;
end;

//
//					//	INITIALISATION DE LA GRILLE	//
//

procedure remplCase(var grille : matrix ; taille : coord ; type_case : integer ; var coord_case : coord);
(* INGOUFF Christian, 11/01/12 *)
var
	valide : boolean;
begin
	repeat
		coord_case[1] := random(taille[1]-1) + 1;
		coord_case[2] := random(taille[1]-1) + 1;
		valide := grille[coord_case[1],coord_case[2]] = 0;
		if valide then
			grille[coord_case[1],coord_case[2]] := type_case;
	until valide;
end;

procedure remiseZero(var grille, grilcoups : matrix ; taille : coord);
var
	i, j : integer;
begin
	for i := 0 to taille[1]-1 do
		for j := 0 to taille[2]-1 do
			if (i = 0) or (j = 0) or (i = taille[1]-1) or (j = taille[2]-1) then
			begin
				grilcoups[i,j] := -42;
				grille[i,j] := -42;
			end
			else
			begin
				grille[i,j] := 0;
				grilcoups[i,j] := -1;
			end;
end;

procedure iniGrille(var grille:matrix; taille : coord ; var tresor, enter, joueur : coord ; difficultymin : integer);
(* Pré-condition : Reçoit un tableau vide de taille définie (non nulle)
   Post-condition : Renvoie la grille remplie
   INGOUFF Christian, 11/01/12 *)
var
	i, nb_coups, nb_murs : integer;
	tmp : coord;
	grilcoups : matrix; // Grille qui va gérer le vérificateur de grilles (nombre de coups)
begin
	setLength(grilcoups,taille[1],taille[2]);
	remiseZero(grille,grilcoups,taille); // Initialise les grilles
	nb_murs := trunc(( 15 / 49 ) * ( (taille[1]-2) * (taille[2]-2) )); // Définit le nombre de murs
	remplCase(grille,taille,42,tresor); // Trésor = 42
	remplCase(grille,taille,10,enter); // Porte d'entrée = 10
	grilcoups[enter[1],enter[2]] := 0; // Point d'entrée pour "dijkstra"
	joueur := enter;
	for i := 1 to nb_murs do
	begin
		remplCase(grille,taille,-42,tmp); // Mur = -42
		grilcoups[tmp[1],tmp[2]] := -42; // Reporte les murs sur la grille pour "dijkstra"
	end;
	dijkstra(grille,grilcoups,tresor,enter,taille,nb_coups);
	if nb_coups < difficultymin then
		iniGrille(grille,taille,tresor,enter,joueur,difficultymin)
	else
	begin
		extracGrille(grille,grilcoups,tresor);
		grille[tresor[1],tresor[2]] := 42;
		grille[enter[1],enter[2]] := 10;
		writeln('Nombre de coups optimal : ',nb_coups,#10,#13);
	end;
end;

//
//					//	DEPLACEMENT DU JOUEUR ET DU BOT		//
//

procedure deplacement(grille : matrix ; var griljoueur : matrix ; var joueur : coord ; enter : coord ; direc : array_coord ; sens : integer ; var valide : boolean);
// Vérifie si une case est libre, si une case correspond à l'entrée et réagit correctement.
// Sens : 1 = haut, 2 = bas, 3 = gauche, 4 = droite (cf. procédure "bouger")
// Valide : Renvoie si le déplacement est valide ou non
begin
	valide := grille[direc[sens,1],direc[sens,2]] > -42;
	if valide then
	begin
		if (joueur[1] = enter[1]) and (joueur[2] = enter[2]) then 
			griljoueur[joueur[1],joueur[2]] := 10
		else
			griljoueur[joueur[1],joueur[2]] := -5;
		joueur := direc[sens];
		griljoueur[joueur[1],joueur[2]] := 14+sens;
	end
	else
	begin
		griljoueur[direc[sens,1],direc[sens,2]] := -42;
		griljoueur[joueur[1],joueur[2]] := 14+sens;
	end;
end;

procedure victory();
begin
	titre();
	writeln('');
	writeln('');
	victoryScreen();
	writeln('');
	writeln('                                    $$$$     BRAVO, vous avez trouvé le trésor !     $$$$',#10,#13);
	writeln('                                               Appuyez sur ENTREE pour rejouer.');
	writeln('                                Appuyez sur n''importe quelle autre touche pour retourner au menu.');
	writeln('');
	repeat
	until KeyPressed;
	clrscr;
end;

function minimum(dist : array_itg):integer;
// INGOUFF Christian, 15/01/12 - Version 1.0
// Retourne le minimum d'un array[1..4] of integer.
var
	i : integer;
begin
	minimum := 1;
	for i := 2 to 4 do
		if (dist[i] < dist[minimum]) then
			minimum := i;
end;
	

procedure eloignement(direc : array_coord ; loc, tresor : coord ; var ordre : array_itg);
// INGOUFF Christian, 15/01/12 - Version 1.0
// Retourne l'ordre : du moins au plus éloigné du trésor
var
	i : integer;
	dist, dist_x, dist_y : array_itg;
begin
	for i := 1 to 4 do
	begin
		dist_x[i] := abs(tresor[1] - direc[i,1]);
		dist_y[i] := abs(tresor[2] - direc[i,2]);
		dist[i] := dist_x[i]*dist_x[i] + dist_y[i]*dist_y[i]; // Distance Pythagore
	end;
	
	for i := 1 to 4 do
	begin
		ordre[i] := minimum(dist); // Assigne le plus petit des 4...
		dist[ordre[i]] := 5000; // ...puis exclut cette valeur en la montant.
	end;
end;

(*procedure bot(grille : matrix ; var grilbot : matrix ; taille, enter, tresor : coord ; var xbot : coord);
// Procédure qui gère le déplacement du bot
var
	i, tmp : integer;
	direc : array_coord;
	valide : boolean;
	ch : char;
	mattmp : matrix;
begin
	setLength(mattmp,taille[1],taille[2]);
	writeln('');
	affichGrille(grilbot,taille);
	repeat until KeyPressed;
	ch := ReadKey;
	arrayDirec(direc,xbot);
	dijkstra(grilbot,mattmp,tresor,xbot,taille,tmp);
	grilbot[xbot[1],xbot[2]] := 10;
	extracGrille(grilbot,mattmp,tresor);
	grilbot[tresor[1],tresor[2]] := 42;
	grilbot[enter[1],enter[2]] := 10;
	i := 1;
	repeat
	if grilbot[direc[i,1],direc[i,2]] = -1 then
	begin
		deplacement(grille,grilbot,xbot,enter,direc,i,valide);
		i := 5;
	end
	else i := i+1;
	until i > 4;
	clrscr;
	if not valide then writeln('BOUH, t''as rencontré un mur !') else writeln('');
	if (xbot[1] = tresor[1]) and (xbot[2] = tresor[2]) then victory()
	else if ch <> #27 then
		bot(grille,grilbot,taille,enter,tresor,xbot);
end;*)

procedure bouger(grille : matrix ; var griljoueur : matrix ; taille, enter, tresor : coord ; var joueur : coord);
// Procédure qui gère le déplacement du pion
var
	direc : array_coord;
	ch : char;
	valide : boolean;
begin
	writeln('');
	affichGrille(griljoueur,taille);
	arrayDirec(direc,joueur); // On obtient les valeurs des cases environnantes
	ch:=ReadKey;
	if KeyPressed then
	begin
		ch:=ReadKey; {Read ScanCode}
		case ch of
		#72 :	deplacement(grille,griljoueur,joueur,enter,direc,1,valide); // Haut
		#80 :	deplacement(grille,griljoueur,joueur,enter,direc,2,valide); // Bas
		#75 :	deplacement(grille,griljoueur,joueur,enter,direc,3,valide); // Gauche
		#77 :	deplacement(grille,griljoueur,joueur,enter,direc,4,valide); // Droite
		#27 :	writeln('Au revoir !');
		end;
	end;
	clrscr;
	if not valide then writeln('BOUH, t''as rencontré un mur !') else writeln('');
	if (joueur[1] = tresor[1]) and (joueur[2] = tresor[2]) then victory()
	else if ch <> #27 then
		bouger(grille,griljoueur,taille,enter,tresor,joueur);
end;

//
//					//	MENU PRINCIPAL	//
//

function ecrireFleche(ok : boolean):string;
begin
   if ok then
   	ecrireFleche:=(' <--')
   else
 	ecrireFleche:=(' ');   
end;

procedure choixMenu(choix:integer);

begin
   clrscr;
   titre();
   writeln('                                                      NOUVELLE PARTIE'+ecrireFleche(choix=0));
   writeln('                                                      PARAMETRES'+ecrireFleche(choix=1));
   writeln('                                                      COMMENT JOUER?'+ecrireFleche(choix=2));
   writeln('                                                      QUITTER'+ecrireFleche(choix=3));
end;

procedure nouvellePartie();
var
	i, j, difficultymin : integer;
	grille, griljoueur : matrix;
	taille, taille2, enter, tresor, joueur : coord;
begin
	clrscr;
	taille[1] := 7;
	taille[2] := 7;
	taille2[1] := taille[1]+2;
	taille2[2] := taille[2]+2;	
	randomize;
	setLength(grille,taille2[1],taille2[2]);
	setLength(griljoueur,taille2[1],taille2[2]);
	writeln('Niveau de difficulté ? (pour l''instant nb min coups)'); // Programmer plusieurs lvl de difficulté :
//	Exemple : pour difficulty = 1, difmin := 4 et difmax := 9, et pour difficulty = infini, difmin := 21
	readln(difficultymin);
	iniGrille(grille,taille2,tresor,enter,joueur,difficultymin);
//	affichGrille(grille,taille);
	for i := 0 to taille2[1]-1 do
		for j := 0 to taille2[2]-1 do
			if (i = 0) or (i = taille2[1]-1) or (j = 0) or (j = taille2[2]-1) then griljoueur[i,j] := -42
			else if (i = joueur[1]) and (j = joueur[2]) then griljoueur[i,j] := 15
			else if (i = tresor[1]) and (j = tresor[2]) then griljoueur[i,j] := 42
			else griljoueur[i,j] := 0;
	clrscr;
	writeln('');
//		bouger(grille,griljoueur,taille,enter,tresor,joueur);
		bot(grille,griljoueur,taille,enter,tresor,joueur);
end;

procedure destinationMenu(choix:integer);
begin
   case choix of
   0: nouvellePartie();{procedure de Nouvelle Partie}
   1: writeln('procedure des parametres');{Procedure des Parametres}
   2: writeln('procedure instruction');
   end;
end;

procedure menuPrincipal(var quit : boolean);
var
   choix : integer;
   ch: char;
begin
 choix:=0;
 ch := '0';
 quit := FALSE;
 repeat
    choixMenu(choix);
    ch:=ReadKey;
    if KeyPressed then
       begin
           ch:=ReadKey; {Read ScanCode}
           case ch of
            #72 : begin
                           choix := (choix - 1); {monte dans le choix}
                        if (choix <0) then
                            choix:=3;
                    end;
            #80 : begin
                    choix := (choix + 1);  {descend dans le choix}
                    if (choix >3) then
                        choix:= 0;
                   end;
           end;
         end;
  
 until (ch=#13);{Esc}
 quit := choix = 3;
 if (ch=#13) and not quit then
 destinationMenu(choix)
 else clrscr;
end;

procedure debutMenu();
var
	quit : boolean;
begin
   clrscr;
   writeln(' ');
   writeln(' ');
   menuPrincipal(quit);
   if not quit then debutMenu();
end;

begin
	clrscr;
	titre();
	writeln(' ');
	writeln(' ');
	logo();
	writeln(' ');
	writeln('                                                           Bienvenue !',#10,#13);
	writeln('                                              Appuyez sur n''importe quelle touche.');
	repeat
	until ReadKey <> #0;
	debutMenu();
end.
