diff options
Diffstat (limited to 'src/squares.ads')
-rw-r--r-- | src/squares.ads | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/src/squares.ads b/src/squares.ads new file mode 100644 index 0000000..7f9b090 --- /dev/null +++ b/src/squares.ads @@ -0,0 +1,96 @@ + + +with + + Things; + +private with + + FLTK.Images.RGB.PNG, + Ada.Command_Line, + Ada.Directories; + + +package Squares is + + + type Square is tagged private; + + + Void : constant Square; + + + Wall : constant Square; + Space : constant Square; + Empty : constant Square; + Goal : constant Square; + + + function Is_Walkable + (This : in Square) + return Boolean; + + + function Get_Contents + (This : in Square) + return Things.Thing + with Pre => Is_Walkable (This); + + + procedure Set_Contents + (This : in out Square; + Item : in Things.Thing) + with Pre => Is_Walkable (This); + + + procedure Draw + (This : in Square; + X, Y : in Integer); + + + function "=" + (A, B : in Square) + return Boolean; + + +private + + + type Square is tagged record + Walkable : Boolean; + Contents : Things.Thing; + Self_Image : access FLTK.Images.RGB.PNG.PNG_Image; + end record; + + + Origin : String := Ada.Directories.Containing_Directory + (Ada.Directories.Full_Name (Ada.Command_Line.Command_Name)); + Image_Dir : String := Origin & "/../share/sokoban/img"; + + + Wall_Image : aliased FLTK.Images.RGB.PNG.PNG_Image := + FLTK.Images.RGB.PNG.Create (Image_Dir & "/wall.png"); + Space_Image : aliased FLTK.Images.RGB.PNG.PNG_Image := + FLTK.Images.RGB.PNG.Create (Image_Dir & "/space.png"); + Empty_Image : aliased FLTK.Images.RGB.PNG.PNG_Image := + FLTK.Images.RGB.PNG.Create (Image_Dir & "/empty.png"); + Goal_Image : aliased FLTK.Images.RGB.PNG.PNG_Image := + FLTK.Images.RGB.PNG.Create (Image_Dir & "/goal.png"); + + + Void : constant Square := + (Walkable => False, Contents => Things.Nothing, Self_Image => null); + + + Wall : constant Square := + (Walkable => False, Contents => Things.Nothing, Self_Image => Wall_Image'Access); + Space : constant Square := + (Walkable => False, Contents => Things.Nothing, Self_Image => Space_Image'Access); + Empty : constant Square := + (Walkable => True, Contents => Things.Nothing, Self_Image => Empty_Image'Access); + Goal : constant Square := + (Walkable => True, Contents => Things.Nothing, Self_Image => Goal_Image'Access); + + +end Squares; + |