Advertisement
moadel

Untitled

Feb 6th, 2021
2,727
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. pac.nbrevies:=maxnbrevies;
  98.       case Dir2 is
  99.    
  100.      when Nord => Verification(Pac.Posx,Pac.Posy+1,Labyr,Pac);
  101.        
  102.      when Sud => Verification(Pac.Posx,Pac.Posy-1,Labyr,Pac);
  103.        
  104.      when Est => Verification(Pac.Posx+1,Pac.Posy,Labyr,Pac);
  105.        
  106.      when Ouest => Verification(Pac.Posx-1,Pac.Posy,Labyr,Pac);
  107.        
  108.      when Immobile => null;
  109.        
  110.       end case;
  111.      
  112.    end Deplacement;
  113.    
  114.    
  115.    
  116.    
  117.    
  118.    procedure Finjeu(L: in Integer) is
  119.      
  120.    begin
  121.       if L=0 then
  122.      Effacerecran;
  123.      Ecrireecran(10,5,"victoire"& "appuyez sur A pour recommencer");
  124.    
  125.    
  126.       else
  127.    
  128.      Effacerecran;
  129.      Ecrireecran(10,5,"game over"&"appuyez sur A pour recommencer");
  130.    
  131.    
  132.       end if;
  133.      
  134.    end Finjeu;
  135.    
  136.    
  137.    procedure Affiche_Nbcerise(Laby:in Lab.T_Lab) is
  138.       Nbrecerise:Integer;
  139.    begin
  140.       Nbrecerise:=Compter_Cerise(Laby);
  141.      
  142.      
  143.       Ecran.Ecrireecran(0,0,"nbre cerises = " & Integer'Image(Nbrecerise));
  144.      
  145.    end Affiche_Nbcerise;
  146.    
  147.    
  148.  
  149.    
  150.    pacman:Lab.T_Pacman;
  151.    labyrinthe:T_Lab;
  152.    Direction :T_Direction;
  153.    Temps:Integer:=Gettempsecoule;
  154.    Nbcerise:Integer:=Compter_Cerise(Labyrinthe);
  155. begin
  156.    
  157.    while True loop
  158.       Initialisercarte;
  159.       Lab.Initialiserjeu(pacman,labyrinthe);
  160.       Mettreazerotimer;
  161.       while Temps<60000 and  Nbcerise/=0 and  Pacman.Nbrevies/=0  loop
  162.      Direction:=DetecterDirection;
  163.      Ecrireecran(20,12, Integer'Image(Temps));
  164.      Affiche_Nbcerise(Labyrinthe);
  165.      Deplacement(Labyrinthe,Pacman,Direction);
  166.       end loop;
  167.       Finjeu(nbcerise);
  168.       AttendretoucheA;
  169.    end loop;
  170.    
  171.    
  172. end missionpacman ;
  173.  
  174.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement