%Programme de simula par Dominique Grenier:Grenied et Sabrina Fuizzotto: %Fuizzots. Pour compiler faites le sim MagicMaze.sim. Le fichier de sauve %garde s'appelle pointage. 17/04/97. % % % Ce programme elabore un labyrinte que l'usager peut s'amuser avec; BEGIN EXTERNAL CLASS DESSIN; APPLICATION CLASS EXEMPLE; BEGIN Integer DimX, !Dimension du labyrinthe en x; DimY, !Dimension du labyrinthe en y; action, !act=0 :partie arretee ou suspendue, act=1 :partie en cours; game, !game=0 :pas de partie en cour , game=1 :partie en cour; h, !h=0 :aide a ete utilise,h=1 :aide n'a pas ete utilise; cx, !position en x du fromage; cy, !position en y du fromage; Maj, !Facteur de magie; fin, !fin=0 :pas rendu a la fin, fin=1 :rendu a la fin; took, !took=0 :pas pris le fromage, took=1 :pris le fromage; best, !meilleur score; chance, !chance: possibilite d'ecoute de la souris; niv, !niveau; subniv, !subniv; score, !score; Mx, !position en x de la souris; My, !position en y de la souris; i, !variable utilitaires; j, !variable utilitaires; U, !seed; X, !variable utilitaires; Y, !variable utilitaires; Dir, !direction prise au hasard; Exit, !position en y de la sortie; Entree, !position en y de l'entree; temps, !temps ecoule; passe, !temps ulterieur; mm, !minutes; ss, !secondes; fresh; !rafraichissement de l'ecran; Text nom; !joueurs; Real Tstart; !Temps de depart d'une partie; Character Wall = 'X'; !declaration du mur; Character array maze (0:56,0:34); !tableau du labyrinthe; ref(button) quitter, !Sortir du programme; difficultees, !changer le niveau de difficultee; restart, !arrivee des boutons; quit_aide, !sortir de l'aide; arret, !pause; choose, !depart de la page titre; aide, !acces a l'aide; high, !acces a score; subd11, !acces au niveau 1.1; subd12, !acces au niveau 1.2; subd13, !acces au niveau 1.3; subd21, !acces au niveau 2.1; subd22, !acces au niveau 2.2; subd23, !acces au niveau 2.3; subd31, !acces au niveau 3.1; subd32, !acces au niveau 3.2; subd33, !acces au niveau 3.3; Niv1, !acces au niveau 1; Niv2, !acces au niveau 2; Niv3; !acces au niveau 3; !--------------------------------------------------------------------------------------------------------------------------------------; !_____________Explication______________________________________________________________________________________________________________; PROCEDURE Explication; Begin Police("Times",14);plume (2); Texte(400,200,"Ce jeu se joue sans la tete a Papineau."); Texte(400,225,"-On n'a qu'a choisir le niveau de difficulte desire et"); Texte(400,250,"gentiment guider la souris vers la sortie. Attention !#!@!, la "); Texte(400,275," souris ne suit pas toujours les conseils"); end Explication; !--------------------------------------------------------------------------------------------------------------------------------------; !_____________page-titre_______________________________________________________________________________________________________________; PROCEDURE pgtitre; Begin fresh := 1; explication; plume (2); choose:- MakeButton("BEGIN THE MADNESS"); Choose.Hide; Nom:-Ask_For_text("Nom "); choose.show; choose.PlaceAt(width/2,300); choose.Wait; arret:-MakeButton("pause"); arret.PlaceAt(160,580); arret.hide; aide:-MakeButton("aide"); high:-MakeButton("scores"); high.PlaceAt(230,580); high.hide; aide.PlaceAt(50,580); Difficultees:-makebutton("Nouveau"); Difficultees.PlaceAt(width/2-80,580); choose.Hide; End pgtitre; !--------------------------------------------------------------------------------------------------------------------------------------; !____________Niv1______________________________________________________________________________________________________________________; PROCEDURE Niveau1; Begin fresh:=0; Effacer_Rect(0,0,815,615); game:=0; took:=1; h:=0; fin:= 0; plume(2); Niv1.Hide; Niv3.Hide; Niv2.Hide; High.hide; subd11:- MakeButton("1"); subd11.PlaceAt(340,580); subd12:- MakeButton("2"); subd12.PlaceAt(428,580); subd13:- MakeButton("3"); subd13.PlaceAt(520,580); End Niveau1; !--------------------------------------------------------------------------------------------------------------------------------------; !____________Niv2______________________________________________________________________________________________________________________; PROCEDURE Niveau2; Begin fresh:=0; Effacer_Rect(0,0,815,615); game:=0; h:=0; took:=0; fin := 0; plume(2); Niv1.Hide; Niv3.Hide; Niv2.Hide; High.hide; subd21:- MakeButton("1"); subd21.PlaceAt(340,580); subd22:-MakeButton("2"); subd22.PlaceAt(428,580); subd23:- MakeButton("3"); subd23.PlaceAt(520,580); end Niveau2; !--------------------------------------------------------------------------------------------------------------------------------------; !____________Niv3______________________________________________________________________________________________________________________; PROCEDURE Niveau3; Begin fresh:=0; Effacer_Rect(0,0,815,615); game:=0; h:=0; took:=1; fin := 0; plume(2); Niv1.Hide; Niv3.Hide; Niv2.Hide; High.hide; subd31:- MakeButton("1"); subd31.PlaceAt(340,580); subd32:- MakeButton("2"); subd32.PlaceAt(428,580); subd33:- MakeButton("3"); subd33.PlaceAt(520,580); End Niveau3; !--------------------------------------------------------------------------------------------------------------------------------------; !____________Depart____________________________________________________________________________________________________________________; PROCEDURE Depart; begin u:=clocktime; Effacer_Rect(0,0,815,615); for i := 0 step 1 until dimX +1 do for j := 0 step 1 until dimY + 1 do maze(i,j) := WALL ; Temps :=0.4; passe :=0; mm:=0; ss:=0; Excavate(1,1, maze); Enter; Sortie; Mx:= dimx; My:= Entree; fresh:=2; PrintMaze(Maze); Pause(2); action:=1; game:=1; tstart:=clocktime; While temps < 20*60 and action =1 do begin horloge; avance; magic; HANDLE_PENDING_EVENTS; end; end Depart; !--------------------------------------------------------------------------------------------------------------------------------------; !____________sousNiv1.1________________________________________________________________________________________________________________; PROCEDURE sub11; begin plume(2); initialiser; subd11.Hide; subd12.Hide; subd13.Hide; arret.show; Difficultees.show; Dimx:=33; Dimy:=33; niv:= 1; subniv:= 1; depart; end sub11; !--------------------------------------------------------------------------------------------------------------------------------------; !____________sousNiv1.2________________________________________________________________________________________________________________; PROCEDURE sub12; begin plume(2); initialiser; subd11.Hide; subd12.Hide; subd13.Hide; arret.show; Difficultees.show; Dimx:=55; Dimy:=33; niv:= 1; subniv:= 2; depart; end sub12 ; !--------------------------------------------------------------------------------------------------------------------------------------; !____________sousNiv1.3________________________________________________________________________________________________________________; PROCEDURE sub13; begin plume(2); initialiser; subd11.Hide; subd12.Hide; subd13.Hide; arret.show; Difficultees.show; Dimx:=55; Dimy:=33; niv:= 1; subniv:= 3; depart; end sub13; !--------------------------------------------------------------------------------------------------------------------------------------; !____________sousNiv2.1________________________________________________________________________________________________________________; PROCEDURE sub21; begin plume(2); initialiser; subd21.Hide; subd22.Hide; subd23.Hide; arret.show; Difficultees.show; Dimx:=33; Dimy:=33; niv:= 2; subniv:= 1; Cheese; depart; end sub21; !--------------------------------------------------------------------------------------------------------------------------------------; !____________sousNiv2.2________________________________________________________________________________________________________________; PROCEDURE sub22; begin plume(2); initialiser; subd21.Hide; subd22.Hide; subd23.Hide; arret.show; Difficultees.show; Dimx:=55; Dimy:=33; niv:= 2; subniv:= 2; Cheese; depart; end sub22; !--------------------------------------------------------------------------------------------------------------------------------------; !____________sousNiv2.3________________________________________________________________________________________________________________; PROCEDURE sub23; begin plume(2); initialiser; subd21.Hide; subd22.Hide; subd23.Hide; arret.show; Difficultees.show; Dimx:=55; Dimy:=33; niv:= 2; subniv:= 3; cheese; depart; end sub23; !--------------------------------------------------------------------------------------------------------------------------------------; !____________sousNiv3.1________________________________________________________________________________________________________________; PROCEDURE sub31; begin plume(2); initialiser; subd31.Hide; subd32.Hide; subd33.Hide; arret.show; Difficultees.show; Dimx:=33; Dimy:=33; niv:= 3; subniv:= 1; depart; end sub31; !--------------------------------------------------------------------------------------------------------------------------------------; !____________sousNiv3.2________________________________________________________________________________________________________________; PROCEDURE sub32; begin plume(2); initialiser; subd31.Hide; subd32.Hide; subd33.Hide; arret.show; Difficultees.show; Dimx:=55; Dimy:=33; niv:= 3; subniv:= 2; depart; end sub32; !-------------------------------------------------------------------------------------------------------------------------------------; !____________sousNiv3.3________________________________________________________________________________________________________________; PROCEDURE sub33; Begin plume(2); initialiser; subd31.Hide; subd32.Hide; subd33.Hide; arret.show; Difficultees.show; Dimx:=55; Dimy:=33; niv:= 3; subniv:= 3; depart; End sub33 ; !--------------------------------------------------------------------------------------------------------------------------------------; !___________redemarrer_________________________________________________________________________________________________________________; procedure more; begin Integer p; plume(2); p:=clocktime; arret.Hide; restart:- MakeButton("replay"); restart.PlaceAt(160,580); restart.Wait; restart.hide; arret.show; fresh:=2; printmaze(maze); Tstart:=tstart+clocktime-p; Action:= 1; End more; !--------------------------------------------------------------------------------------------------------------------------------------; !___________Aide_______________________________________________________________________________________________________________________; Procedure HelpTxt; begin plume(2); Texte(400,75,"Chaque niveau de difficultee a trois sous-niveau. Le niveau facile a"); Texte(400,100,"seulement des dimensions differentes. En plus, le niveau moyen a un"); Texte(400,125,"fromage vert a aller chercher. Le niveau impossible reserve une surprise !"); Texte(400,150,"Attention, le troisieme sous-niveau de chaque niveau de difficulte"); Texte(400,175,"est dans la noirceur presque totale. "); end HelpTxt; !-------------------------------------------------------------------------------------------------------------------------------------; !___________HELP______________________________________________________________________________________________________________________; Procedure Help; Begin Integer d; if game = 1 and H=0 and fin = 0 then begin d:=clocktime; trymaze(0,exit,maze); printmaze(maze); pause (2); H:=1; Action:= 1; Tstart:=Tstart+clocktime-d; end else begin d:=clocktime; initialiser; fresh:=3; HelpTxt; aide.Hide; Quit_aide:-MakeButton("Quit aide"); Quit_aide.PlaceAt(50,580); Quit_aide.wait; initialiser; Quit_aide.hide; aide.show; fresh:=2; if game = 1 then printmaze(maze); Tstart:=Tstart+clocktime-d; Action:= 1; end; end help; !--------------------------------------------------------------------------------------------------------------------------------------; !___________Replay_____________________________________________________________________________________________________________________; Procedure Replay; Begin Difficultees.Hide; arret.hide; plume (2) ; Niv1:- MakeButton("Facile"); Niv1.PlaceAt(400,580); Niv2:- MakeButton("moyen"); Niv2.PlaceAt(471,580); Niv3:- MakeButton("impossible"); Niv3.PlaceAt(543,580); End Replay; !--------------------------------------------------------------------------------------------------------------------------------------; !___________N__Difficultees____________________________________________________________________________________________________________; PROCEDURE Button_press(n); REF(Button) N; Begin fresh:=0; action := 0; IF N == Niv1 THEN Niveau1 else IF N == Niv2 THEN Niveau2 else IF N == Niv3 THEN Niveau3 else IF N == Subd11 THEN sub11 else IF N == Subd12 THEN sub12 else IF N == subd13 THEN sub13 else IF N == Subd21 THEN sub21 else IF N == subd22 THEN sub22 else IF N == Subd23 THEN sub23 else IF N == Subd31 THEN sub31 else IF N == Subd32 THEN sub32 else IF N == subd33 THEN sub33 else IF N == Difficultees THEN replay else IF N == arret THEN more else IF N == aide THEN Help else IF N == high THEN meilleurs; End button; !------------------------------------------------------------------------------------------------------------------------------------; !____________Crayon&Efface___________________________________________________________________________________________________________; !------------------------------------------------------------------------------------------------------------------------------------; !____________Efface__________________________________________________________________________________________________________________; procedure efface; begin plume(1); Maze(Mx,My):= 'p'; effacer_rect (Mx*14+8,My*14+75,(Mx+1)*14+9,(My+1)*14+76); Couleur("gray50"); if Maze(Mx-1,My) = 'X' then begin rectangle ((Mx-1)*14+8,My*14+75,(Mx)*14+8,(My+1)*14+75,1); end; if Maze(Mx+1,My) = 'X' then begin rectangle ((Mx+1)*14+8,My*14+75,(Mx+2)*14+8,(My+1)*14+75,1); end; if Maze(Mx,My-1) = 'X' then begin rectangle (Mx*14+8,(My-1)*14+75,(Mx+1)*14+8,(My)*14+75,1); end; if Maze(Mx,My+1) = 'X' then begin rectangle (Mx*14+8,(My+1)*14+75,(Mx+1)*14+8,(My+2)*14+75,1); end; plume(2); end efface; !--------------------------------------------------------------------------------------------------------------------------------------; !_______________Crayon_________________________________________________________________________________________________________________; procedure Crayon; begin plume (1); Maze(Mx,My):='S'; Couleur("black"); rectangle (Mx*14+8,My*14+75,(Mx+1)*14+8,(My+1)*14+75,1); plume (2); end Crayon; !--------------------------------------------------------------------------------------------------------------------------------------; !________________aleatoire_____________________________________________________________________________________________________________; procedure avance; begin integer z; z:=clocktime*3000; dir:= randint(1,4,z); chance:=randint(1,100,z); If dir=1 and Maze(Mx-1,My) = 'X' then dir:= 2 else if dir=2 and Maze(Mx+1,My) = 'X'then dir:= 3 else If dir=3 and Maze(Mx,My-1) ='X' then dir:= 4 else if dir=4 and Maze(Mx,My+1) = 'X' then dir:= 1 else ; IF chance <50 and action = 1 then begin IF dir=1 and Maze (0,My) <> 'X' and Mx = 1 and took = 1 THEN Begin efface; Mx:=Mx-1; Maze(Mx,My):='S'; Crayon; ending; end else IF dir=1 and Maze(Mx-1,My) <> 'X' and Mx > 1 THEN Begin efface; if (Mx-1) = Cx and My = Cy then took:=1; Mx:=Mx-1; Maze(Mx,My):='S'; Crayon; pause(0.2); end ELSE IF dir=2 and Maze(Mx+1,My) <> 'X' and Mx < dimx then Begin efface; if (Mx+1) = Cx and My = Cy then took:=1; Mx:=Mx+1; Maze(Mx,My):='S'; Crayon; pause(0.2); end ELSE IF Dir=3 and Maze(Mx,My-1) <> 'X' and My > 1 then Begin efface; if Mx = Cx and (My-1) = Cy then took:=1; My:=My-1; Maze(Mx,My):='S'; Crayon; pause(0.2); end ELSE IF Dir=4 and Maze(Mx,My+1) <> 'X' and My < dimy then Begin efface; if Mx = Cx and (My+1) = Cy then took:=1; My:=My+1; Maze(Mx,My):='S'; Crayon; pause(0.2); end; end; end avance; !--------------------------------------------------------------------------------------------------------------------------------------; !____________Fleches___________________________________________________________________________________________________________________; PROCEDURE HANDLE_SPECIAL_KEY_DOWN (Key_code); Integer Key_code; begin if Action = 1 then begin IF key_code = 16Rff51 and Maze(0,My) <> 'X' and Mx = 1 and took = 1 then Begin efface; Mx:=Mx-1; Maze(Mx,My):='S'; Crayon; ending; end else IF key_code = 16Rff51 and Maze(Mx-1,My) <> 'X' and Mx > 1 then Begin efface; if (Mx-1) = Cx and My = Cy then took:=1; Mx:=Mx-1; Maze(Mx,My):='S'; Crayon; end else IF key_code = 16Rff53 and Maze(Mx+1,My) <> 'X' and Mx < dimx then Begin efface; if (Mx+1) = Cx and My = Cy then took:=1; Mx:=Mx+1; Maze(Mx,My):='S'; Crayon; end else IF key_code = 16Rff52 and Maze(Mx,My-1) <> 'X' and My > 1 then Begin efface; if Mx = Cx and (My-1) = Cy then took:=1; My:=My-1; Maze(Mx,My):='S'; Crayon; end else IF key_code = 16Rff54 and Maze(Mx,My+1) <> 'X' and My < dimy then Begin efface; if Mx = Cx and (My+1) = Cy then took:=1; My:=My+1; Maze(Mx,My):='S'; Crayon; end; end; horloge; end fleches; !--------------------------------------------------------------------------------------------------------------------------------------; !____________Horloge___________________________________________________________________________________________________________________; procedure Horloge; Begin temps:=entier (clocktime - Tstart); if temps > passe and Action = 1 then begin police("times",14); plume(2); mm:=Temps//60; ss:=Temps-mm*60; Effacer_Rect(710,30,790,50); if mm > 9 then texte(724,36, int_as_text(mm) & "") else texte(724,36, "0" & int_as_text(mm)); if ss > 9 then texte(744,36, ":" & int_as_text(ss)) else texte(744,36, ":0" & int_as_text(ss)); passe:=temps; end; End Horloge; !--------------------------------------------------------------------------------------------------------------------------------------; !____________Magic_____________________________________________________________________________________________________________________; procedure Magic; begin integer i; i:= 15*subniv; if temps// i > Maj and niv = 3 and rem(Mx,2) > 0 and rem(My,2) > 0 then begin real t; action:= 0; t:=clocktime; for i := 0 step 1 until dimX +1 do for j := 0 step 1 until dimY + 1 do maze(i,j) := WALL ; Effacer_rect(2,73,815,600); Sortie; Excavate(1,1, maze); Maze (Mx,My):= 'S'; if h = 1 then Trymaze (0,exit,maze); PrintMaze(Maze); Maj:= Maj+1; action:= 1; tstart := Tstart+(clocktime-t); end; End Magic; !--------------------------------------------------------------------------------------------------------------------------------------; !____________Out_Labyrinthe____________________________________________________________________________________________________________; procedure Excavate (x,y,M); integer x,y; character array M; Begin integer i,d,d1; M(x,y):= ' '; d1:= randint(1,4,U); for i:= 1 step 1 until 4 do begin d:= mod(d1+i,4); if d=0 and x2 and then M(x-2,y) = Wall then begin M(x-1,y):= ' '; Excavate(x-2,y,M) end else if d=2 and y2 and then M(x,y-2) = Wall then begin M(x,y-1):= ' '; Excavate(x,y-2,M) end end; end Excavate ; !--------------------------------------------------------------------------------------------------------------------------------------; !___________________Sortie_____________________________________________________________________________________________________________; procedure Sortie; begin U:= clocktime*1.5; Exit:= randint(1,Dimy//2-1,U); Exit:= 2*Exit+1; Maze(0,exit):= 'E'; end Sortie; !--------------------------------------------------------------------------------------------------------------------------------------; !___________________Entree_____________________________________________________________________________________________________________; procedure Enter; begin U:= clocktime*2.5; Entree:= randint(1,DimY//2-1,U); Entree:= 2*Entree+1; Maze(dimx,entree):= 'S'; end Entree; !--------------------------------------------------------------------------------------------------------------------------------------; !___________________Cheese_____________________________________________________________________________________________________________; procedure Cheese; begin U:= clocktime; cy:= randint(1,Dimy//2-2,U); cy:= 2*cy+1; U:= clocktime; cx:= randint(1,Dimx//2-1,U); cx:= 2*cx+1; end Cheese; !--------------------------------------------------------------------------------------------------------------------------------------; !___________________Try_Maze___________________________________________________________________________________________________________; Boolean procedure tryMaze(x,y,M); integer x,y; character array M; if M(x,y) = 'S' then tryMaze := true else if M(x,y) = ' ' or M(x,y) = 'p' or M(x,y) = 'E' then BEGIN integer i,j,d; Boolean Trouve; Maze(x,y) := '.'; while not trouve and d<4 do begin if d=0 and x0 and then M(x-1,y) = ' ' OR M(x-1,y) = 'S' OR M(x-1,y) = 'p' then trouve := tryMaze(x-1,y,M) else if d=2 and y0 and then M(x,y-1) = ' ' OR M(x,y-1) = 'S' OR M(x,y-1) = 'p' then trouve := tryMaze(x,y-1,M); d:= d+1; end; if trouve then begin tryMaze:= trouve; d:= d-1; if d=0 then M(x,y) := '.' else if d=1 then M(x,y) := '.' else if d=2 then M(x,y) := '.' else if d=3 then M(x,y) := '.'; end else M(x,y) := ' '; if niv = 2 then M (cx,cy):= 'C'; END tryMaze; !--------------------------------------------------------------------------------------------------------------------------------------; !____________Out_Maze__________________________________________________________________________________________________________________; procedure PrintMaze(M); character array M; begin integer i, j; police("times",14); Plume(2); rectangle(10,10,805,13,0); rectangle(10,60,805,63,0); rectangle(20,10,23,63,0); rectangle(792,10,795,63,0); rectangle(605,10,608,63,0); rectangle(324,35,608,38,0); rectangle(324,10,327,63,0); rectangle(230,10,233,63,0); texte(120,36,"-MAGICMAZE-"); texte(390,23,"A BATTRE:"); texte(520,23,int_as_text(best)&"" ); texte(390,49,"Dernier score:"); texte(520,49,int_as_text(score)&"" ); texte(675,36,"TEMPS:"); if mm > 9 then texte(724,36, int_as_text(mm) & "") else texte(724,36, "0" & int_as_text(mm)); if ss > 9 then texte(744,36, ":" & int_as_text(ss)) else texte(744,36, ":0" & int_as_text(ss)); police("times",10); texte(278,25,"NIVEAU:"); police("times",12); texte(278,45, int_as_text(niv)& "." & int_as_text(subniv)); plume(1); for i := 0 step 1 until dimx + 1 do for j := 0 step 1 until dimy + 1 do begin if M(i,j) = 'X' then begin Couleur("gray50"); if subniv = 3 and fin = 0 and i > 0 and i <= dimx and j > 0 and j <= dimy then begin if M(i+1,j) <> 'p' and M(i-1,j) <> 'p' and M(i,j+1) <> 'p' and M(i,j-1) <> 'p' then Couleur("gray20"); end; rectangle (i*14+8,j*14+75,(i+1)*14+8,(j+1)*14+75,1); end; if M(i,j) = ' ' and subniv = 3 and fin = 0 and M(i,j) <> 'E' then begin Couleur("gray20"); rectangle (i*14+8,j*14+75,(i+1)*14+8,(j+1)*14+75,1); end; if M(i,j) = '.' then begin Couleur("gray5"); rectangle (i*14+8,j*14+75,(i+1)*14+8,(j+1)*14+75,1); end; if M(i,j) = 'S' then begin Couleur("black"); rectangle (i*14+8,j*14+75,(i+1)*14+8,(j+1)*14+75,2); end; if i = Cx and j = Cy and took = 0 then begin Couleur("gray25"); rectangle (i*14+8,j*14+75,(i+1)*14+8,(j+1)*14+75,1); end; end; Plume(2); end PrintMaze; !----------------------------Les-fichiers--------------------------------------------; !______________________________________________________________; procedure meilleurs; BEGIN REF(dessin) endWindow; REF(Scrollwindow) secondwindow; REF(button) Qbutton; endWindow :- MakeDessin("Meilleurs joutes"); Secondwindow :- endWindow.MakeScrollWindow; Secondwindow.setsize(Secondwindow.width, Secondwindow.height - 40); QButton:-endWindow.MakeButton("retour").PlaceAt(205,260); inspect new infile("pointage") do BEGIN IF open(blanks(80)) then BEGIN WHILE not lastitem do BEGIN Secondwindow.puttext(image.strip); Secondwindow.outimage; inimage; END; close; END ELSE BEGIN Secondwindow.puttext("rien"); Secondwindow.outimage; END; END; QButton.wait; endWindow.hide; QButton.hide; Secondwindow.destroy; endWindow.destroy; END; !______________________________________________________________________________; procedure nouveau_meilleurs; BEGIN text array names(1 : 10); integer array resultat(1 : 10); integer incr, i; inspect new infile("pointage") do BEGIN IF open(blanks(80)) then BEGIN WHILE not lastitem do BEGIN WHILE image.getchar <> ':' do; image.getchar; incr := incr + 1; names(incr) :- copy(image.sub(1, image.pos - 2).strip); resultat(incr) := image.sub(image.pos, image.length - image.pos - 2).getint; inimage; END; close; END; END; IF score > resultat(10) then BEGIN IF incr <> 10 then incr := incr + 1; i := 9; WHILE i >= 1 and then resultat(i) < score do BEGIN resultat(i + 1) := resultat(i); names(i + 1) :- names(i); i := i - 1; END; names(i + 1) :- nom; resultat(i + 1) := score; inspect new outfile("pointage") do BEGIN IF open(blanks(80)) then BEGIN for i := 1 step 1 until incr do BEGIN outtext(names(i)); outtext(": "); outtext(int_as_text(resultat(i))); outimage; END; close; END; END; !---------------------------------------------------------------------------; BEGIN REF(dessin) fenWindow; REF(Scrollwindow) firstwindow; REF(button) Qbutton; fenWindow :- MakeDessin("Scores"); firstwindow :- fenWindow.MakeScrollWindow; firstwindow.placeat(firstwindow.min_x, firstwindow.min_y + 40); firstwindow.setsize(firstwindow.width, firstwindow.height - 80); QButton:- fenWindow.MakeButton("retour").PlaceAt(207,265); fenWindow.police("times", 18); fenWindow.texte (fenwindow.width // 2, 25, "Bravo!"); for i := 1 step 1 until incr do BEGIN firstwindow.puttext(names(i) & ": " & int_as_text(resultat(i))); firstwindow.outimage; END; QButton.wait; fenWindow.hide; QButton.Hide; firstwindow.destroy; fenWindow.destroy; END; END END; !--------------------------------------------------------------------------------------------------------------------------------------; !___points_____________________________________________________________________________________________________________________________; procedure point; begin integer bonus; if niv=1 then bonus:=10 else if niv=2 then bonus:=20 else bonus:=30; if h=0 then bonus:= bonus//2; score:=((20*60-temps)*niv*bonus*subniv*5); end point ; !-------------------------------------------------------------------------------------------------------------------------------------; !___ending____________________________________________________________________________________________________________________________; procedure ending; begin action:=0; fin := 1; point; arret.hide; if score > best then best := score; Nouveau_meilleurs; Effacer_Rect(0,0,815,615); PrintMaze(Maze); high.show; end ending; !-------------------------------------------------------------------------------------------------------------------------------------; !______refresh________________________________________________________________________________________________________________________; PROCEDURE Refresh; Begin If fresh=3 then HelpTxt; If fresh=2 then printmaze(maze); If fresh=1 then explication ; End Refresh; !--------------------------------------------------------------------------------------------------------------------------------------; !--------Programme principal-----------------------------------------------------------------------------------------------------------; placeat(100,100); SETSIZE(815,615); pgtitre; replay; Initialiser; quitter:-makebutton("au revoir"); quitter.placedownright; quitter.wait; End; NEW exemple (" Labyrinthe "); END