aboutsummaryrefslogtreecommitdiff
path: root/game.ads
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2019-12-07 18:24:37 +0100
committerCharles <sircharlesaze@gmail.com>2019-12-07 18:24:37 +0100
commitc06bc6767163f0215d0c12e04d5a0a54d7d8a167 (patch)
tree4bd1e85cb041ec29584757a4a64caba5355a5e01 /game.ads
parente0dd50831fd19e1145897de8af909002c2821376 (diff)
downloadsnake-c06bc6767163f0215d0c12e04d5a0a54d7d8a167.tar.gz
snake-c06bc6767163f0215d0c12e04d5a0a54d7d8a167.tar.bz2
snake-c06bc6767163f0215d0c12e04d5a0a54d7d8a167.zip
Basic Game logic
Diffstat (limited to 'game.ads')
-rw-r--r--game.ads33
1 files changed, 32 insertions, 1 deletions
diff --git a/game.ads b/game.ads
index a58a59f..67247c8 100644
--- a/game.ads
+++ b/game.ads
@@ -1,8 +1,39 @@
+with Queue;
+
package Game is
+ type T_Position is record
+ x: Natural;
+ y: Natural;
+ end record;
+
+ package P_Position_Queue is new Queue(T_Position);
+ use P_Position_Queue;
+
+ type T_Direction is (
+ DIRECTION_UP,
+ DIRECTION_DOWN,
+ DIRECTION_LEFT,
+ DIRECTION_RIGHT
+ );
+
type T_Game is record
- null;
+ height: Positive;
+ width: Positive;
+ snake: T_Queue;
+ direction: T_Direction;
+ food: T_Position;
end record;
+ procedure Init(game: out T_Game;
+ width: Positive;
+ height: Positive);
+ function Next(game: in out T_Game) return Boolean;
+
+private
+
+ procedure Spawn_Food(game: in out T_Game);
+ function Next_Head(game: T_Game) return T_Position;
+ function In_Border(game: T_Game; pos: T_Position) return Boolean;
end Game;