aboutsummaryrefslogtreecommitdiff
path: root/src/squares.ads
blob: 3eca22f7eeed384da9a4b777c02a629dd95b5d07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100


--  Programmed by Jedidiah Barber
--  Licensed under the Sunset License v1.0

--  See license.txt for further details


with

    Things;

private with

    Ada.Directories,
    FLTK.Images.RGB.PNG,
    Misc;


package Squares is


    type Square is tagged private;

    Void : constant Square;

    Wall  : constant Square;
    Space : constant Square;
    Empty : constant Square;
    Goal  : constant Square;

    function "="
           (A, B : in Square)
        return Boolean;




    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);


private


    type Square is tagged record
        Walkable   : Boolean;
        Contents   : Things.Thing;
        Self_Image : access FLTK.Images.RGB.PNG.PNG_Image;
    end record;


    Wall_Image  : aliased FLTK.Images.RGB.PNG.PNG_Image := FLTK.Images.RGB.PNG.Forge.Create
        (Ada.Directories.Compose (Misc.Image_Path, "wall.png"));
    Space_Image : aliased FLTK.Images.RGB.PNG.PNG_Image := FLTK.Images.RGB.PNG.Forge.Create
        (Ada.Directories.Compose (Misc.Image_Path, "space.png"));
    Empty_Image : aliased FLTK.Images.RGB.PNG.PNG_Image := FLTK.Images.RGB.PNG.Forge.Create
        (Ada.Directories.Compose (Misc.Image_Path, "empty.png"));
    Goal_Image  : aliased FLTK.Images.RGB.PNG.PNG_Image := FLTK.Images.RGB.PNG.Forge.Create
        (Ada.Directories.Compose (Misc.Image_Path, "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;