Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with Ecran , Lab , Carte ;
- use Ecran , Lab , Carte ;
- with Ecran , Lab , Carte ;
- use Ecran , Lab , Carte ;
- procedure missionpacman is
- function Compter_Cerise(Laby:in Lab.T_Lab) return integer is
- Compt:Integer:=0;
- begin
- for Lig in laby'Range(1) loop
- for Col in laby'Range(2) loop
- if Laby(Lig,Col)=Cerise then
- Compt:=Compt+1;
- else
- null;
- end if;
- end loop;
- end loop;
- return Compt;
- end Compter_Cerise;
- procedure Mettre_Mur (Pac:in out T_Pacman;Labyr:T_lab) is
- begin
- Pac.Nbrevies:=Pac.Nbrevies-1;
- Suspendretimer;
- Effacerecran;
- Ecrireecran(20,8,"mur touche");
- Reprendretimer;
- Dessinerlabyrinthe(Labyr);
- end mettre_Mur;
- procedure Verification (X:in Integer; Y: in Integer; Labyr:in T_Lab;Pac:in out T_pacman) is
- begin
- if Labyr(X,Y)= Cerise then
- Dessinerbloc(x,y,Vide);
- Pac.Posx:=X;
- Pac.Posy:=Y;
- Dessinerbloc(Pac.posx,Pac.posy,Lab.Pacman);
- Dessinerlabyrinthe(Labyr);
- elsif Labyr(X,Y)= Mur then
- Mettre_Mur(Pac,Labyr);
- elsif Labyr(X,Y)= Vide then
- Pac.Posx:=X;
- Pac.Posy:=Y;
- Dessinerbloc(Pac.Posx,Pac.Posy,Lab.Pacman);
- Dessinerlabyrinthe(Labyr);
- else
- null;
- end if;
- end Verification;
- procedure Deplacement(labyr:in Lab.T_Lab; Pac: in out Lab.T_Pacman;Dir2:in out T_Direction) is
- begin
- case Dir2 is
- when Nord => Verification(Pac.Posx,Pac.Posy+1,Labyr,Pac);
- when Sud => Verification(Pac.Posx,Pac.Posy-1,Labyr,Pac);
- when Est => Verification(Pac.Posx+1,Pac.Posy,Labyr,Pac);
- when Ouest => Verification(Pac.Posx-1,Pac.Posy,Labyr,Pac);
- when Immobile => null;
- end case;
- end Deplacement;
- procedure Finjeu(L: in Integer) is
- begin
- if L=0 then
- Effacerecran;
- Ecrireecran(10,5,"victoire"& "appuyez sur A pour recommencer");
- else
- Effacerecran;
- Ecrireecran(10,5,"game over"&"appuyez sur A pour recommencer");
- end if;
- end Finjeu;
- procedure Affiche_Nbcerise(Laby:in Lab.T_Lab) is
- Nbrecerise:Integer;
- begin
- Nbrecerise:=Compter_Cerise(Laby);
- Ecran.Ecrireecran(0,0,"nbre cerises = " & Integer'Image(Nbrecerise));
- end Affiche_Nbcerise;
- pacman:Lab.T_Pacman;
- labyrinthe:T_Lab;
- Direction :T_Direction;
- Temps:Integer:=Gettempsecoule;
- Nbcerise:Integer:=Compter_Cerise(Labyrinthe);
- begin
- while True loop
- Initialisercarte;
- Lab.Initialiserjeu(pacman,labyrinthe);
- Mettreazerotimer;
- while Temps<60000 and Nbcerise/=0 and Pacman.Nbrevies/=0 loop
- Direction:=DetecterDirection;
- Ecrireecran(20,12, Integer'Image(Temps));
- Affiche_Nbcerise(Labyrinthe);
- Deplacement(Labyrinthe,Pacman,Direction);
- end loop;
- Finjeu(nbcerise);
- AttendretoucheA;
- end loop;
- end missionpacman ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement