aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJedidiah Barber <contact@jedbarber.id.au>2025-04-18 20:13:41 +1200
committerJedidiah Barber <contact@jedbarber.id.au>2025-04-18 20:13:41 +1200
commit525b5641fee7154d5be1a66420ca15d54bb6f6ce (patch)
treeb0f6944bbfc5626096c7cd47702c8d4b7ebccaf0 /src
parentce2ba2c8bdd7070d7688eff83173b6725c0fe657 (diff)
Consolidated image data
Diffstat (limited to 'src')
-rw-r--r--src/data.ads82
-rw-r--r--src/displays.adb3
-rw-r--r--src/displays.ads9
-rw-r--r--src/misc.adb17
-rw-r--r--src/misc.ads47
-rw-r--r--src/moves.adb6
-rw-r--r--src/moves.ads4
-rw-r--r--src/pathfinding.adb12
-rw-r--r--src/sokoban.adb16
-rw-r--r--src/squares.ads23
-rw-r--r--src/things.ads20
11 files changed, 111 insertions, 128 deletions
diff --git a/src/data.ads b/src/data.ads
new file mode 100644
index 0000000..8ab5a4b
--- /dev/null
+++ b/src/data.ads
@@ -0,0 +1,82 @@
+
+
+-- Programmed by Jedidiah Barber
+-- Licensed under the Sunset License v1.0
+
+-- See license.txt for further details
+
+
+with
+
+ FLTK.Images.RGB.PNG;
+
+private with
+
+ Ada.Directories,
+ Here_I_Am;
+
+
+package Data is
+
+
+ Origin, Image_Path, Level_Path : constant String;
+
+
+ Man_Image : constant access FLTK.Images.RGB.PNG.PNG_Image;
+ Treasure_Image : constant access FLTK.Images.RGB.PNG.PNG_Image;
+
+
+ Wall_Image : constant access FLTK.Images.RGB.PNG.PNG_Image;
+ Space_Image : constant access FLTK.Images.RGB.PNG.PNG_Image;
+ Empty_Image : constant access FLTK.Images.RGB.PNG.PNG_Image;
+ Goal_Image : constant access FLTK.Images.RGB.PNG.PNG_Image;
+
+
+private
+
+
+ package ADir renames Ada.Directories;
+
+
+ Origin : constant String := ADir.Containing_Directory (Here_I_Am.Executable);
+
+ Image_Path : constant String :=
+ ADir.Compose
+ (ADir.Compose
+ (ADir.Compose
+ (ADir.Compose (Origin, ".."), "share"), "sokoban"), "img");
+
+ Level_Path : constant String :=
+ ADir.Compose
+ (ADir.Compose
+ (ADir.Compose
+ (ADir.Compose (Origin, ".."), "share"), "sokoban"), "level");
+
+
+ Man_Actual : aliased FLTK.Images.RGB.PNG.PNG_Image :=
+ FLTK.Images.RGB.PNG.Forge.Create (ADir.Compose (Image_Path, "man.png"));
+ Treasure_Actual : aliased FLTK.Images.RGB.PNG.PNG_Image :=
+ FLTK.Images.RGB.PNG.Forge.Create (ADir.Compose (Image_Path, "treasure.png"));
+
+ Man_Image : constant access FLTK.Images.RGB.PNG.PNG_Image := Man_Actual'Access;
+ Treasure_Image : constant access FLTK.Images.RGB.PNG.PNG_Image := Treasure_Actual'Access;
+
+
+ Wall_Actual : aliased FLTK.Images.RGB.PNG.PNG_Image :=
+ FLTK.Images.RGB.PNG.Forge.Create (ADir.Compose (Image_Path, "wall.png"));
+ Space_Actual : aliased FLTK.Images.RGB.PNG.PNG_Image :=
+ FLTK.Images.RGB.PNG.Forge.Create (ADir.Compose (Image_Path, "space.png"));
+ Empty_Actual : aliased FLTK.Images.RGB.PNG.PNG_Image :=
+ FLTK.Images.RGB.PNG.Forge.Create (ADir.Compose (Image_Path, "empty.png"));
+ Goal_Actual : aliased FLTK.Images.RGB.PNG.PNG_Image :=
+ FLTK.Images.RGB.PNG.Forge.Create (ADir.Compose (Image_Path, "goal.png"));
+
+ Wall_Image : constant access FLTK.Images.RGB.PNG.PNG_Image := Wall_Actual'Access;
+ Space_Image : constant access FLTK.Images.RGB.PNG.PNG_Image := Space_Actual'Access;
+ Empty_Image : constant access FLTK.Images.RGB.PNG.PNG_Image := Empty_Actual'Access;
+ Goal_Image : constant access FLTK.Images.RGB.PNG.PNG_Image := Goal_Actual'Access;
+
+
+end Data;
+
+
diff --git a/src/displays.adb b/src/displays.adb
index 9893db3..5b9885d 100644
--- a/src/displays.adb
+++ b/src/displays.adb
@@ -8,6 +8,7 @@
with
+ Data,
FLTK.Screen,
FLTK.Events;
@@ -50,7 +51,7 @@ package body Displays is
This.Level_Box.Set_Label_Size (Text_Size);
This.Move_Box.Set_Label_Size (Text_Size);
- This.Set_Icon (Logo);
+ This.Set_Icon (Data.Man_Image.all);
end return;
end Create;
diff --git a/src/displays.ads b/src/displays.ads
index d4229fb..381b97e 100644
--- a/src/displays.ads
+++ b/src/displays.ads
@@ -13,10 +13,7 @@ with
private with
- Ada.Directories,
- FLTK.Widgets.Boxes,
- FLTK.Images.RGB.PNG,
- Misc;
+ FLTK.Widgets.Boxes;
package Displays is
@@ -113,10 +110,6 @@ private
end record;
- Logo : FLTK.Images.RGB.PNG.PNG_Image := FLTK.Images.RGB.PNG.Forge.Create
- (Ada.Directories.Compose (Misc.Image_Path, "man.png"));
-
-
Text_Size : constant FLTK.Font_Size := 12;
Message_Box_Width : constant Integer := 440;
diff --git a/src/misc.adb b/src/misc.adb
deleted file mode 100644
index 009836c..0000000
--- a/src/misc.adb
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
--- Programmed by Jedidiah Barber
--- Licensed under the Sunset License v1.0
-
--- See license.txt for further details
-
-
-package body Misc is
-
-
- -- null
-
-
-end Misc;
-
-
diff --git a/src/misc.ads b/src/misc.ads
deleted file mode 100644
index 7108f63..0000000
--- a/src/misc.ads
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
--- Programmed by Jedidiah Barber
--- Licensed under the Sunset License v1.0
-
--- See license.txt for further details
-
-
-private with
-
- Ada.Directories,
- Here_I_Am;
-
-
-package Misc is
-
-
- pragma Elaborate_Body;
-
-
- Origin, Image_Path, Level_Path : constant String;
-
-
-private
-
-
- package ADir renames Ada.Directories;
-
-
- Origin : constant String := ADir.Containing_Directory (Here_I_Am.Executable);
-
- Image_Path : constant String :=
- ADir.Compose
- (ADir.Compose
- (ADir.Compose
- (ADir.Compose (Origin, ".."), "share"), "sokoban"), "img");
-
- Level_Path : constant String :=
- ADir.Compose
- (ADir.Compose
- (ADir.Compose
- (ADir.Compose (Origin, ".."), "share"), "sokoban"), "level");
-
-
-end Misc;
-
-
diff --git a/src/moves.adb b/src/moves.adb
index 58bbbf9..c2ee332 100644
--- a/src/moves.adb
+++ b/src/moves.adb
@@ -18,10 +18,10 @@ package body Moves is
procedure Add
- (This : in out Path;
- List : in Path) is
+ (This : in out Path;
+ Items : in Path) is
begin
- This.Append (List);
+ This.Append (Items);
end Add;
diff --git a/src/moves.ads b/src/moves.ads
index a8e18df..f58513f 100644
--- a/src/moves.ads
+++ b/src/moves.ads
@@ -32,8 +32,8 @@ package Moves is
Item : in Move);
procedure Add
- (This : in out Path;
- List : in Path);
+ (This : in out Path;
+ Items : in Path);
procedure Prefix
(This : in out Path;
diff --git a/src/pathfinding.adb b/src/pathfinding.adb
index ca4cbda..267b0a3 100644
--- a/src/pathfinding.adb
+++ b/src/pathfinding.adb
@@ -8,9 +8,9 @@
with
- Things,
+ Ada.Containers.Ordered_Maps,
Ada.Containers.Ordered_Sets,
- Ada.Containers.Ordered_Maps;
+ Things;
package body Pathfinding is
@@ -33,8 +33,6 @@ package body Pathfinding is
(Key_Type => Node, Element_Type => Node);
-
-
subtype G_Score is Integer;
subtype F_Score is Integer;
@@ -70,8 +68,6 @@ package body Pathfinding is
end F_Min;
-
-
function Reconstruct_Path
(Came_From : in Node_To_Node_Maps.Map;
Current : in Node)
@@ -91,8 +87,6 @@ package body Pathfinding is
end Reconstruct_Path;
-
-
function Heuristic
(A, B : in Node)
return Integer is
@@ -101,8 +95,6 @@ package body Pathfinding is
end Heuristic;
-
-
function Neighbours
(My_Grid : in Grids.Grid;
Current : in Node)
diff --git a/src/sokoban.adb b/src/sokoban.adb
index a2206ee..d8a7f0e 100644
--- a/src/sokoban.adb
+++ b/src/sokoban.adb
@@ -9,17 +9,17 @@
with
Ada.Directories,
- FLTK.Widgets,
+ Ada.Strings.Fixed,
+ Ada.Strings.Maps,
+ Ada.Text_IO,
+ Data,
Displays,
+ FLTK.Widgets,
Grids,
- Squares,
- Things,
Moves,
Pathfinding,
- Misc,
- Ada.Text_IO,
- Ada.Strings.Fixed,
- Ada.Strings.Maps;
+ Squares,
+ Things;
use
@@ -99,7 +99,7 @@ package body Sokoban is
Data_File : File_Type;
Filename : constant String := ADir.Compose
- (Misc.Level_Path, "level" & Trim (LevelID'Image (Number), Both) & ".data");
+ (Data.Level_Path, "level" & Trim (LevelID'Image (Number), Both) & ".data");
Rows, Cols : Natural;
begin
diff --git a/src/squares.ads b/src/squares.ads
index 3eca22f..b4ced0f 100644
--- a/src/squares.ads
+++ b/src/squares.ads
@@ -12,9 +12,8 @@ with
private with
- Ada.Directories,
- FLTK.Images.RGB.PNG,
- Misc;
+ Data,
+ FLTK.Images.RGB.PNG;
package Squares is
@@ -71,28 +70,18 @@ private
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);
+ (Walkable => False, Contents => Things.Nothing, Self_Image => Data.Wall_Image);
Space : constant Square :=
- (Walkable => False, Contents => Things.Nothing, Self_Image => Space_Image'Access);
+ (Walkable => False, Contents => Things.Nothing, Self_Image => Data.Space_Image);
Empty : constant Square :=
- (Walkable => True, Contents => Things.Nothing, Self_Image => Empty_Image'Access);
+ (Walkable => True, Contents => Things.Nothing, Self_Image => Data.Empty_Image);
Goal : constant Square :=
- (Walkable => True, Contents => Things.Nothing, Self_Image => Goal_Image'Access);
+ (Walkable => True, Contents => Things.Nothing, Self_Image => Data.Goal_Image);
end Squares;
diff --git a/src/things.ads b/src/things.ads
index 4f35b64..c594c95 100644
--- a/src/things.ads
+++ b/src/things.ads
@@ -8,9 +8,8 @@
private with
- Ada.Directories,
- FLTK.Images.RGB.PNG,
- Misc;
+ Data,
+ FLTK.Images.RGB.PNG;
package Things is
@@ -43,20 +42,11 @@ private
end record;
- Man_Image : aliased FLTK.Images.RGB.PNG.PNG_Image := FLTK.Images.RGB.PNG.Forge.Create
- (Ada.Directories.Compose (Misc.Image_Path, "man.png"));
- Treasure_Image : aliased FLTK.Images.RGB.PNG.PNG_Image := FLTK.Images.RGB.PNG.Forge.Create
- (Ada.Directories.Compose (Misc.Image_Path, "treasure.png"));
+ Nothing : constant Thing := (Self_Image => null);
- Nothing : constant Thing :=
- (Self_Image => null);
-
-
- Man : constant Thing :=
- (Self_Image => Man_Image'Access);
- Treasure : constant Thing :=
- (Self_Image => Treasure_Image'Access);
+ Man : constant Thing := (Self_Image => Data.Man_Image);
+ Treasure : constant Thing := (Self_Image => Data.Treasure_Image);
end Things;