![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
testing documentation
Dependencies: mbed ll16j23s_test_docs
SnakeBody/SnakeBody.h@6:6c9453397f4a, 2020-05-23 (annotated)
- Committer:
- JoeShotton
- Date:
- Sat May 23 20:01:00 2020 +0000
- Revision:
- 6:6c9453397f4a
- Parent:
- 4:ea3fa51c4386
- Child:
- 7:dd84e0fab346
Implemented screen transition function
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JoeShotton | 3:fcd6d70e9694 | 1 | #ifndef SNAKEBODY_H |
JoeShotton | 3:fcd6d70e9694 | 2 | #define SNAKEBODY_H |
JoeShotton | 3:fcd6d70e9694 | 3 | |
JoeShotton | 3:fcd6d70e9694 | 4 | #include "mbed.h" |
JoeShotton | 3:fcd6d70e9694 | 5 | #include "N5110.h" |
JoeShotton | 3:fcd6d70e9694 | 6 | #include "Gamepad.h" |
JoeShotton | 3:fcd6d70e9694 | 7 | #include <vector> |
JoeShotton | 3:fcd6d70e9694 | 8 | |
JoeShotton | 3:fcd6d70e9694 | 9 | class SnakeBody |
JoeShotton | 3:fcd6d70e9694 | 10 | { |
JoeShotton | 3:fcd6d70e9694 | 11 | struct Direction { |
JoeShotton | 4:ea3fa51c4386 | 12 | int delta_x; // increment value for x |
JoeShotton | 4:ea3fa51c4386 | 13 | int delta_y; // increment value for y |
JoeShotton | 4:ea3fa51c4386 | 14 | int nextState[5]; // array of next states |
JoeShotton | 3:fcd6d70e9694 | 15 | }; |
JoeShotton | 3:fcd6d70e9694 | 16 | |
JoeShotton | 3:fcd6d70e9694 | 17 | public: |
JoeShotton | 3:fcd6d70e9694 | 18 | |
JoeShotton | 3:fcd6d70e9694 | 19 | SnakeBody(); |
JoeShotton | 3:fcd6d70e9694 | 20 | ~SnakeBody(); |
JoeShotton | 4:ea3fa51c4386 | 21 | void init(); |
JoeShotton | 4:ea3fa51c4386 | 22 | void snake_movement(Gamepad &pad); |
JoeShotton | 4:ea3fa51c4386 | 23 | void draw_body(N5110 &lcd); |
JoeShotton | 4:ea3fa51c4386 | 24 | void snake_snake_collision(Gamepad &pad, bool &death); //(int _x_head, int _y_head, vector<int> _body_x, vector<int> _body_y, int _length); |
JoeShotton | 4:ea3fa51c4386 | 25 | |
JoeShotton | 4:ea3fa51c4386 | 26 | int _state; |
JoeShotton | 4:ea3fa51c4386 | 27 | int _x_head; |
JoeShotton | 4:ea3fa51c4386 | 28 | int _y_head; |
JoeShotton | 4:ea3fa51c4386 | 29 | int _length; |
JoeShotton | 6:6c9453397f4a | 30 | |
JoeShotton | 6:6c9453397f4a | 31 | std::vector<int> _body_x; |
JoeShotton | 6:6c9453397f4a | 32 | std::vector<int> _body_y; |
JoeShotton | 3:fcd6d70e9694 | 33 | /* |
JoeShotton | 3:fcd6d70e9694 | 34 | void init(int x,int height,int width); |
JoeShotton | 3:fcd6d70e9694 | 35 | void draw(N5110 &lcd); |
JoeShotton | 3:fcd6d70e9694 | 36 | void update(Direction d,float mag); |
JoeShotton | 3:fcd6d70e9694 | 37 | void add_score(); |
JoeShotton | 3:fcd6d70e9694 | 38 | int get_score(); |
JoeShotton | 3:fcd6d70e9694 | 39 | Vector2D get_pos(); |
JoeShotton | 3:fcd6d70e9694 | 40 | */ |
JoeShotton | 3:fcd6d70e9694 | 41 | private: |
JoeShotton | 3:fcd6d70e9694 | 42 | |
JoeShotton | 4:ea3fa51c4386 | 43 | int update_direction(float _angle, int _x_head, int _y_head); //int _angle, int _x_head, int _y_head |
JoeShotton | 4:ea3fa51c4386 | 44 | void update_position(); //int _d, int _state, int &_x_head, int &_y_head |
JoeShotton | 4:ea3fa51c4386 | 45 | void update_body(); |
JoeShotton | 4:ea3fa51c4386 | 46 | |
JoeShotton | 4:ea3fa51c4386 | 47 | float _angle; |
JoeShotton | 4:ea3fa51c4386 | 48 | int _d; |
JoeShotton | 3:fcd6d70e9694 | 49 | |
JoeShotton | 3:fcd6d70e9694 | 50 | /* |
JoeShotton | 3:fcd6d70e9694 | 51 | int _height; |
JoeShotton | 3:fcd6d70e9694 | 52 | int _width; |
JoeShotton | 3:fcd6d70e9694 | 53 | int _x; |
JoeShotton | 3:fcd6d70e9694 | 54 | int _y; |
JoeShotton | 3:fcd6d70e9694 | 55 | int _speed; |
JoeShotton | 3:fcd6d70e9694 | 56 | int _score; |
JoeShotton | 3:fcd6d70e9694 | 57 | */ |
JoeShotton | 3:fcd6d70e9694 | 58 | }; |
JoeShotton | 3:fcd6d70e9694 | 59 | #endif |