![](/media/cache/profiles/LinkedIn_0NghoZJ.jpeg.50x50_q85.jpg)
Snake vs Block Game to be run upon K64F.
SnakeFood/SnakeFood.h@38:30e4e6191762, 2019-04-22 (annotated)
- Committer:
- AhmedPlaymaker
- Date:
- Mon Apr 22 04:24:38 2019 +0000
- Revision:
- 38:30e4e6191762
- Parent:
- 36:dfdd619874ae
- Child:
- 41:4edac50f010d
This might be the biggest yet!!! THIS HAS MOTION CONTROL
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AhmedPlaymaker | 9:d1d79d4ee673 | 1 | #ifndef SNAKEFOOD_H |
AhmedPlaymaker | 9:d1d79d4ee673 | 2 | #define SNAKEFOOD_H |
AhmedPlaymaker | 9:d1d79d4ee673 | 3 | |
AhmedPlaymaker | 9:d1d79d4ee673 | 4 | #include "mbed.h" |
AhmedPlaymaker | 9:d1d79d4ee673 | 5 | #include "N5110.h" |
AhmedPlaymaker | 9:d1d79d4ee673 | 6 | #include "Gamepad.h" |
AhmedPlaymaker | 9:d1d79d4ee673 | 7 | |
AhmedPlaymaker | 9:d1d79d4ee673 | 8 | |
AhmedPlaymaker | 9:d1d79d4ee673 | 9 | class SnakeFood |
AhmedPlaymaker | 9:d1d79d4ee673 | 10 | { |
AhmedPlaymaker | 9:d1d79d4ee673 | 11 | public: |
AhmedPlaymaker | 9:d1d79d4ee673 | 12 | SnakeFood(); |
AhmedPlaymaker | 9:d1d79d4ee673 | 13 | ~SnakeFood(); |
AhmedPlaymaker | 9:d1d79d4ee673 | 14 | |
AhmedPlaymaker | 9:d1d79d4ee673 | 15 | /** Initialise SnakeFood |
AhmedPlaymaker | 9:d1d79d4ee673 | 16 | * |
AhmedPlaymaker | 9:d1d79d4ee673 | 17 | * This function initialises the SnakeFood library. |
AhmedPlaymaker | 9:d1d79d4ee673 | 18 | */ |
AhmedPlaymaker | 9:d1d79d4ee673 | 19 | void init(); |
AhmedPlaymaker | 9:d1d79d4ee673 | 20 | |
AhmedPlaymaker | 9:d1d79d4ee673 | 21 | /** Draw |
AhmedPlaymaker | 9:d1d79d4ee673 | 22 | * |
AhmedPlaymaker | 9:d1d79d4ee673 | 23 | * This function draws the SnakeFood sprite onto the screen. |
AhmedPlaymaker | 9:d1d79d4ee673 | 24 | */ |
AhmedPlaymaker | 36:dfdd619874ae | 25 | void draw(N5110 &lcd, int blockbuff); |
AhmedPlaymaker | 9:d1d79d4ee673 | 26 | |
AhmedPlaymaker | 9:d1d79d4ee673 | 27 | /** Update |
AhmedPlaymaker | 9:d1d79d4ee673 | 28 | * |
AhmedPlaymaker | 9:d1d79d4ee673 | 29 | * This function updates the position of the SnakeFood as it moves down the screen. |
AhmedPlaymaker | 9:d1d79d4ee673 | 30 | */ |
AhmedPlaymaker | 9:d1d79d4ee673 | 31 | void update(); |
AhmedPlaymaker | 9:d1d79d4ee673 | 32 | |
AhmedPlaymaker | 9:d1d79d4ee673 | 33 | /** Get Position |
AhmedPlaymaker | 9:d1d79d4ee673 | 34 | * |
AhmedPlaymaker | 9:d1d79d4ee673 | 35 | * This function obtains the coordinates of the top-left pixel in the SnakeFood sprite. |
AhmedPlaymaker | 9:d1d79d4ee673 | 36 | */ |
AhmedPlaymaker | 9:d1d79d4ee673 | 37 | Vector2D get_pos(); |
AhmedPlaymaker | 9:d1d79d4ee673 | 38 | |
AhmedPlaymaker | 9:d1d79d4ee673 | 39 | /** Set Position |
AhmedPlaymaker | 9:d1d79d4ee673 | 40 | * |
AhmedPlaymaker | 9:d1d79d4ee673 | 41 | * This function is used to change the position of the sprite to specific coordinates when called. |
AhmedPlaymaker | 9:d1d79d4ee673 | 42 | */ |
AhmedPlaymaker | 9:d1d79d4ee673 | 43 | void set_pos(Vector2D p); |
AhmedPlaymaker | 38:30e4e6191762 | 44 | Vector2D velocity; |
AhmedPlaymaker | 9:d1d79d4ee673 | 45 | |
AhmedPlaymaker | 9:d1d79d4ee673 | 46 | private: |
AhmedPlaymaker | 9:d1d79d4ee673 | 47 | int n; |
AhmedPlaymaker | 9:d1d79d4ee673 | 48 | int _fx; //food x |
AhmedPlaymaker | 9:d1d79d4ee673 | 49 | int _fy; //food y |
AhmedPlaymaker | 9:d1d79d4ee673 | 50 | int fooddrop; //this makes food 1,2,and 3 drop at reasonable speeds |
AhmedPlaymaker | 38:30e4e6191762 | 51 | int _blockbuff; |
AhmedPlaymaker | 9:d1d79d4ee673 | 52 | |
AhmedPlaymaker | 9:d1d79d4ee673 | 53 | }; |
AhmedPlaymaker | 9:d1d79d4ee673 | 54 | #endif |