diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-12-07 18:24:37 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-12-07 18:24:37 +0100 |
| commit | c06bc6767163f0215d0c12e04d5a0a54d7d8a167 (patch) | |
| tree | 4bd1e85cb041ec29584757a4a64caba5355a5e01 /game.ads | |
| parent | e0dd50831fd19e1145897de8af909002c2821376 (diff) | |
| download | snake-c06bc6767163f0215d0c12e04d5a0a54d7d8a167.tar.gz snake-c06bc6767163f0215d0c12e04d5a0a54d7d8a167.tar.bz2 snake-c06bc6767163f0215d0c12e04d5a0a54d7d8a167.zip | |
Basic Game logic
Diffstat (limited to 'game.ads')
| -rw-r--r-- | game.ads | 33 |
1 files changed, 32 insertions, 1 deletions
@@ -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; |
