
Final Commit
Dependencies: mbed
Snake/Snake.h@10:62d8cb7742c3, 2018-04-04 (annotated)
- Committer:
- JRM1986
- Date:
- Wed Apr 04 12:25:51 2018 +0000
- Revision:
- 10:62d8cb7742c3
- Parent:
- 9:561e5681b7a6
- Child:
- 11:e260c17a0489
Function to set and return direction works in low level test, unable to implement as FSM as of yet.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JRM1986 | 2:ea90cec2489a | 1 | #ifndef SNAKE_H |
JRM1986 | 2:ea90cec2489a | 2 | #define SNAKE_H |
JRM1986 | 2:ea90cec2489a | 3 | |
JRM1986 | 2:ea90cec2489a | 4 | #include "mbed.h" |
JRM1986 | 3:50f01159c61d | 5 | #include "FXOS8700CQ.h" |
JRM1986 | 3:50f01159c61d | 6 | #include "Gamepad.h" |
JRM1986 | 2:ea90cec2489a | 7 | #include "N5110.h" |
JRM1986 | 2:ea90cec2489a | 8 | |
JRM1986 | 9:561e5681b7a6 | 9 | struct StateDirection { |
JRM1986 | 9:561e5681b7a6 | 10 | |
JRM1986 | 9:561e5681b7a6 | 11 | Direction output; |
JRM1986 | 9:561e5681b7a6 | 12 | Direction nextState[4]; |
JRM1986 | 9:561e5681b7a6 | 13 | |
JRM1986 | 9:561e5681b7a6 | 14 | }; |
JRM1986 | 9:561e5681b7a6 | 15 | |
JRM1986 | 9:561e5681b7a6 | 16 | |
JRM1986 | 2:ea90cec2489a | 17 | /** Snake Class |
JRM1986 | 1:c3fdbc4b1293 | 18 | * @brief Describes the methods and functions for the snake |
JRM1986 | 1:c3fdbc4b1293 | 19 | * @author Joshua R. Marshall |
JRM1986 | 1:c3fdbc4b1293 | 20 | * @date Feb, 2018 |
JRM1986 | 2:ea90cec2489a | 21 | */ |
JRM1986 | 9:561e5681b7a6 | 22 | |
JRM1986 | 2:ea90cec2489a | 23 | class Snake |
JRM1986 | 2:ea90cec2489a | 24 | { |
JRM1986 | 2:ea90cec2489a | 25 | |
JRM1986 | 2:ea90cec2489a | 26 | public: |
JRM1986 | 9:561e5681b7a6 | 27 | |
JRM1986 | 2:ea90cec2489a | 28 | Snake(); // constructor |
JRM1986 | 2:ea90cec2489a | 29 | ~Snake(); // destructor |
JRM1986 | 9:561e5681b7a6 | 30 | void init(); |
JRM1986 | 10:62d8cb7742c3 | 31 | void update(Direction in, Direction cur); |
JRM1986 | 9:561e5681b7a6 | 32 | void draw(N5110 &lcd); |
JRM1986 | 9:561e5681b7a6 | 33 | |
JRM1986 | 10:62d8cb7742c3 | 34 | void set_snake_direction(Direction input, Direction current); |
JRM1986 | 9:561e5681b7a6 | 35 | Direction get_snake_direction(); |
JRM1986 | 10:62d8cb7742c3 | 36 | void set_snake_position(Direction next); |
JRM1986 | 9:561e5681b7a6 | 37 | Vector2D get_snake_position(); |
JRM1986 | 2:ea90cec2489a | 38 | |
JRM1986 | 2:ea90cec2489a | 39 | private: |
JRM1986 | 9:561e5681b7a6 | 40 | |
JRM1986 | 9:561e5681b7a6 | 41 | Direction _direction; |
JRM1986 | 10:62d8cb7742c3 | 42 | Direction _next; |
JRM1986 | 9:561e5681b7a6 | 43 | int _x; |
JRM1986 | 9:561e5681b7a6 | 44 | int _y; |
JRM1986 | 9:561e5681b7a6 | 45 | |
JRM1986 | 2:ea90cec2489a | 46 | }; |
JRM1986 | 2:ea90cec2489a | 47 | #endif |