Advertisement
moadel

Untitled

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