![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Owen Cavender 201159294
snake.h@2:44e4a6ecdbef, 2020-05-26 (annotated)
- Committer:
- el17oc
- Date:
- Tue May 26 18:35:44 2020 +0000
- Revision:
- 2:44e4a6ecdbef
- Parent:
- 1:897160a1a3ae
ELEC2645
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el17oc | 1:897160a1a3ae | 1 | |
el17oc | 1:897160a1a3ae | 2 | #ifndef SNAKE_H |
el17oc | 1:897160a1a3ae | 3 | #define SNAKE_H |
el17oc | 1:897160a1a3ae | 4 | |
el17oc | 1:897160a1a3ae | 5 | #include "mbed.h" |
el17oc | 1:897160a1a3ae | 6 | #include "N5110.h" |
el17oc | 1:897160a1a3ae | 7 | #include "Gamepad.h" |
el17oc | 1:897160a1a3ae | 8 | #include "GameEngine.h" |
el17oc | 1:897160a1a3ae | 9 | |
el17oc | 1:897160a1a3ae | 10 | |
el17oc | 1:897160a1a3ae | 11 | class Snake |
el17oc | 1:897160a1a3ae | 12 | { |
el17oc | 1:897160a1a3ae | 13 | |
el17oc | 1:897160a1a3ae | 14 | |
el17oc | 1:897160a1a3ae | 15 | public: |
el17oc | 1:897160a1a3ae | 16 | Snake(); |
el17oc | 1:897160a1a3ae | 17 | ~Snake(); |
el17oc | 1:897160a1a3ae | 18 | |
el17oc | 1:897160a1a3ae | 19 | enum Directions { |
el17oc | 1:897160a1a3ae | 20 | up, |
el17oc | 1:897160a1a3ae | 21 | down, |
el17oc | 1:897160a1a3ae | 22 | left, |
el17oc | 1:897160a1a3ae | 23 | right, |
el17oc | 1:897160a1a3ae | 24 | null |
el17oc | 1:897160a1a3ae | 25 | }; |
el17oc | 1:897160a1a3ae | 26 | |
el17oc | 1:897160a1a3ae | 27 | void init(); |
el17oc | 1:897160a1a3ae | 28 | int set_direction(Gamepad &pad); |
el17oc | 1:897160a1a3ae | 29 | //Directions get_direction(); |
el17oc | 2:44e4a6ecdbef | 30 | void move_and_draw_snake(Gamepad &pad, N5110 &lcd); |
el17oc | 1:897160a1a3ae | 31 | void gameover_true(N5110 &lcd); |
el17oc | 1:897160a1a3ae | 32 | void check_if_scored(N5110 &lcd, Gamepad &pad); |
el17oc | 1:897160a1a3ae | 33 | void check_wall_collisions(); |
el17oc | 1:897160a1a3ae | 34 | // void render(N5110 &lcd); |
el17oc | 1:897160a1a3ae | 35 | void clear_applepos(N5110 &lcd); |
el17oc | 1:897160a1a3ae | 36 | |
el17oc | 1:897160a1a3ae | 37 | |
el17oc | 1:897160a1a3ae | 38 | |
el17oc | 1:897160a1a3ae | 39 | |
el17oc | 1:897160a1a3ae | 40 | private: |
el17oc | 1:897160a1a3ae | 41 | |
el17oc | 1:897160a1a3ae | 42 | bool _gameover; |
el17oc | 1:897160a1a3ae | 43 | Directions _direction; |
el17oc | 1:897160a1a3ae | 44 | int _length; |
el17oc | 1:897160a1a3ae | 45 | int _score; |
el17oc | 1:897160a1a3ae | 46 | GameEngine _engine; |
el17oc | 1:897160a1a3ae | 47 | |
el17oc | 1:897160a1a3ae | 48 | |
el17oc | 1:897160a1a3ae | 49 | }; |
el17oc | 1:897160a1a3ae | 50 | |
el17oc | 1:897160a1a3ae | 51 | |
el17oc | 1:897160a1a3ae | 52 | #endif |