Advertisement
moadel

Untitled

Feb 6th, 2021
2,516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ada 3.33 KB | None | 0 0
  1.  
  2.  
  3.  
  4. with Ecran ,  Lab , Carte ;
  5. use  Ecran ,  Lab , Carte ;
  6.  
  7.  
  8. procedure missionpacman is
  9.    
  10.  
  11.  
  12.    function Compter_Cerise(Laby:in Lab.T_Lab) return integer is
  13.  
  14.       Compt:Integer:=0;
  15.      
  16.    begin
  17.      
  18.      
  19.       for Lig in laby'Range(1) loop
  20.      for Col in laby'Range(2) loop
  21.        
  22.        
  23.         if  Laby(Lig,Col)=Cerise then
  24.            Compt:=Compt+1;
  25.         else
  26.            null;
  27.            
  28.            
  29.         end if;
  30.      end loop;
  31.       end loop;
  32.       return Compt;
  33.      
  34.    end Compter_Cerise;
  35.    
  36.    
  37.    
  38.    
  39.    procedure Mettre_Mur (Pac:in out T_Pacman;Labyr:T_lab) is
  40.      
  41.    begin
  42.      
  43.       Pac.Nbrevies:=Pac.Nbrevies-1;
  44.       Suspendretimer;
  45.       Effacerecran;
  46.       Ecrireecran(20,8,"mur touche");
  47.       Reprendretimer;
  48.       Dessinerlabyrinthe(Labyr);
  49.      
  50.      
  51.    end mettre_Mur;
  52.    
  53.    
  54.    
  55.    procedure Verification (X:in  Integer; Y: in  Integer; Labyr:in T_Lab;Pac:in out T_pacman) is
  56.      
  57.    begin
  58.      
  59.      
  60.       if Labyr(X,Y)= Cerise then
  61.    
  62.      Dessinerbloc(x,y,Vide);
  63.      Pac.Posx:=X;
  64.      Pac.Posy:=Y;
  65.      Dessinerbloc(Pac.posx,Pac.posy,Lab.Pacman);
  66.      Dessinerlabyrinthe(Labyr);
  67.    
  68.       elsif Labyr(X,Y)= Mur then
  69.    
  70.      Mettre_Mur(Pac,Labyr);
  71.    
  72.       elsif Labyr(X,Y)= Vide then
  73.    
  74.    
  75.      Pac.Posx:=X;
  76.      Pac.Posy:=Y;
  77.      Dessinerbloc(Pac.Posx,Pac.Posy,Lab.Pacman);
  78.      Dessinerlabyrinthe(Labyr);
  79.    
  80.       else
  81.      null;
  82.    
  83.      end if;
  84.    
  85.       end Verification;
  86.    
  87.  
  88.      
  89.      
  90.    
  91.  
  92.    procedure Deplacement(labyr:in Lab.T_Lab; Pac: in out Lab.T_Pacman;Dir2:in out T_Direction) is
  93.      
  94.    begin
  95.      
  96.       case Dir2 is
  97.    
  98.      when Nord => Verification(Pac.Posx,Pac.Posy+1,Labyr,Pac);
  99.        
  100.      when Sud => Verification(Pac.Posx,Pac.Posy-1,Labyr,Pac);
  101.        
  102.      when Est => Verification(Pac.Posx+1,Pac.Posy,Labyr,Pac);
  103.        
  104.      when Ouest => Verification(Pac.Posx-1,Pac.Posy,Labyr,Pac);
  105.        
  106.      when Immobile => null;
  107.        
  108.       end case;
  109.      
  110.    end Deplacement;
  111.    
  112.    
  113.    
  114.    
  115.    
  116.    procedure Finjeu(L: in Integer) is
  117.      
  118.    begin
  119.       if L=0 then
  120.      Effacerecran;
  121.      Ecrireecran(10,5,"victoire"& "appuyez sur A pour recommencer");
  122.    
  123.    
  124.       else
  125.    
  126.      Effacerecran;
  127.      Ecrireecran(10,5,"game over"&"appuyez sur A pour recommencer");
  128.    
  129.    
  130.       end if;
  131.      
  132.    end Finjeu;
  133.    
  134.    
  135.    procedure Affiche_Nbcerise(Laby:in Lab.T_Lab) is
  136.       Nbrecerise:Integer;
  137.    begin
  138.       Nbrecerise:=Compter_Cerise(Laby);
  139.      
  140.      
  141.       Ecran.Ecrireecran(0,0,"nbre cerises = " & Integer'Image(Nbrecerise));
  142.      
  143.    end Affiche_Nbcerise;
  144.    
  145.    
  146.    
  147.    
  148.  
  149.    
  150.    
  151.    
  152.    pacman:Lab.T_Pacman;
  153.    labyrinthe:T_Lab;
  154.    Direction :T_Direction;
  155.    Temps:Integer:=Gettempsecoule;
  156.    Nbcerise:Integer:=Compter_Cerise(Labyrinthe);
  157. begin
  158.    
  159.    while True loop
  160.       Initialisercarte;
  161.       Lab.Initialiserjeu(pacman,labyrinthe);
  162.       Mettreazerotimer;
  163.       while Temps<60000 and  Nbcerise/=0 and  Pacman.Nbrevies/=0  loop
  164.      Direction:=DetecterDirection;
  165.      Ecrireecran(20,12, Integer'Image(Temps));
  166.      Affiche_Nbcerise(Labyrinthe);
  167.      Deplacement(Labyrinthe,Pacman,Direction);
  168.       end loop;
  169.       Finjeu(nbcerise);
  170.       AttendretoucheA;
  171.    end loop;
  172.    
  173.    
  174. end missionpacman ;
  175.  
  176.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement