mission1.adb

with GAda.Graphics ;
with Plongee ;
with Gada.Text_IO ;

procedure Mission1 is

   package Gr renames GAda.Graphics ;
   package PP renames Plongee ;
   package Txt renames Gada.Text_IO ;

   type T_Coords is record
      PosX, PosY : Integer ;
   end record ;

   -- Trace un cercle ou un disque
   procedure Disque (Position : T_Coords ; Duree : Natural) is
      Couleur : Gr.T_Couleur := (255, 80, 80) ;
   begin
      if Duree = 0 then Gr.Cercle(Position.PosX, Position.PosY, 5, Couleur) ;
      else Gr.Disque(Position.PosX, Position.PosY, 5, Couleur) ;
      end if ;
   end Disque ;

   -- (Il n'etait pas demandé de tester les procedures.)
   procedure Tester_Disque is
      Pos : T_Coords ;
   begin
      Pos := (50,50) ;
      Disque (Pos, 10) ;

      Pos := (100,50) ;
      Disque (Pos, 0) ;
   end Tester_Disque ;

   -- Transformation d'un couple (D, P) en coordonnees
   function Transformer (D : PP.T_Duree ; P : PP.T_Profondeur) return T_Coords is
      Coords : T_Coords ;
   begin
      Coords.PosX := 40 + (D * 420) / 36 ;
      Coords.PosY := 360 - (P * 320) / 6 ;
      return Coords ;
   end Transformer ;

   -- Test : affichage du resultat de la transformation
   procedure Tester_Transformer(D : PP.T_Duree ; P : PP.T_Profondeur) is
      Coords : T_Coords ;
   begin
      Coords := Transformer(D, P) ;
      Txt.Put_Line ("Transformer (" & Integer'Image(D) & ", " &
                    Integer'Image(P) & ") = (" &
                    Integer'Image(Coords.PosX) & ", " &
                    Integer'Image(Coords.PosY) & ")" ) ;
   end Tester_Transformer ;

   -- Dessine un resultat
   procedure Dessine_Resultat (Res : PP.T_Resultat ; Co : T_Coords) is
   begin
      if Res.Definis then
         Disque((Co.PosX, Co.PosY+20), Res.Sequence.Trois) ;
         Disque((Co.PosX, Co.PosY+10), Res.Sequence.Six) ;
         Disque(Co, Res.Sequence.Neuf) ;
         Disque((Co.PosX, Co.PosY-10), Res.Sequence.Douze) ;
         Disque((Co.PosX, Co.PosY-20), Res.Sequence.Quinze) ;
      end if ;
   end Dessine_Resultat ;

   procedure Tester_Resultat is
   begin
      Dessine_Resultat (PP.Table(3,6), (200,200)) ;
   end Tester_Resultat ;

   procedure Dessine_Ligne (P : PP.T_Profondeur) is
   begin
      for D in PP.T_Duree loop
         Dessine_Resultat (PP.Table(P,D), Transformer(D,P)) ;
      end loop ;
   end Dessine_Ligne ;

   procedure Dessine_Table is
   begin
      for P in PP.T_Profondeur loop
         Dessine_Ligne(P) ;
      end loop ;
   end Dessine_Table ;

begin

   Gr.Resize(500,400) ;
   --Tester_Disque ;
   --Tester_Transformer (0,0) ;
   --Tester_Transformer (36,6) ;
   --Tester_Resultat ;

   Dessine_Table ;
end Mission1 ;