
Final Commit
Dependencies: mbed
Food/Food.h@27:bd0f69a75d8b, 2018-05-08 (annotated)
- Committer:
- JRM1986
- Date:
- Tue May 08 12:32:46 2018 +0000
- Revision:
- 27:bd0f69a75d8b
- Parent:
- 26:23301f48c1ed
Final Commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
JRM1986 | 2:ea90cec2489a | 1 | #ifndef FOOD_H |
JRM1986 | 2:ea90cec2489a | 2 | #define FOOD_H |
JRM1986 | 2:ea90cec2489a | 3 | |
JRM1986 | 2:ea90cec2489a | 4 | #include "mbed.h" |
JRM1986 | 3:50f01159c61d | 5 | #include "Gamepad.h" |
JRM1986 | 2:ea90cec2489a | 6 | #include "N5110.h" |
JRM1986 | 2:ea90cec2489a | 7 | |
JRM1986 | 22:7f81fca01f02 | 8 | /** Frame_counting function */ |
JRM1986 | 15:4c97fe30f3b7 | 9 | |
JRM1986 | 22:7f81fca01f02 | 10 | int g_frame_counter(); // |
JRM1986 | 22:7f81fca01f02 | 11 | |
JRM1986 | 22:7f81fca01f02 | 12 | static int g_fc; /**< int for frame counter */ |
JRM1986 | 3:50f01159c61d | 13 | |
JRM1986 | 2:ea90cec2489a | 14 | /** Food Class |
JRM1986 | 22:7f81fca01f02 | 15 | * @brief Describes the methods and functions for the food class |
JRM1986 | 1:c3fdbc4b1293 | 16 | * @author Joshua R. Marshall |
JRM1986 | 1:c3fdbc4b1293 | 17 | * @date Feb, 2018 |
JRM1986 | 2:ea90cec2489a | 18 | */ |
JRM1986 | 2:ea90cec2489a | 19 | |
JRM1986 | 2:ea90cec2489a | 20 | class Food |
JRM1986 | 2:ea90cec2489a | 21 | { |
JRM1986 | 2:ea90cec2489a | 22 | |
JRM1986 | 2:ea90cec2489a | 23 | public: |
JRM1986 | 2:ea90cec2489a | 24 | Food(); // constructor |
JRM1986 | 2:ea90cec2489a | 25 | ~Food(); // destructor |
JRM1986 | 3:50f01159c61d | 26 | |
JRM1986 | 22:7f81fca01f02 | 27 | /** Initialise position of food */ |
JRM1986 | 22:7f81fca01f02 | 28 | |
JRM1986 | 18:406fc298a7c4 | 29 | void init(bool collision); |
JRM1986 | 22:7f81fca01f02 | 30 | |
JRM1986 | 22:7f81fca01f02 | 31 | /** Updates food state */ |
JRM1986 | 22:7f81fca01f02 | 32 | |
JRM1986 | 25:f03439ee32c6 | 33 | void update(bool collision, int n_frames); |
JRM1986 | 22:7f81fca01f02 | 34 | |
JRM1986 | 22:7f81fca01f02 | 35 | /** Draws food on lcd */ |
JRM1986 | 22:7f81fca01f02 | 36 | |
JRM1986 | 21:63c5590cb2c2 | 37 | void draw(N5110 &lcd); |
JRM1986 | 21:63c5590cb2c2 | 38 | |
JRM1986 | 22:7f81fca01f02 | 39 | /** Gets a random position for spawning food */ |
JRM1986 | 22:7f81fca01f02 | 40 | |
JRM1986 | 22:7f81fca01f02 | 41 | Vector2D get_rand_pos(); |
JRM1986 | 21:63c5590cb2c2 | 42 | |
JRM1986 | 22:7f81fca01f02 | 43 | /** @brief resets food position when collsion event or a set number of frames have passed |
JRM1986 | 22:7f81fca01f02 | 44 | @param set_frames corresponds to frame counter |
JRM1986 | 22:7f81fca01f02 | 45 | @param number_frames number of frames before resetting food position |
JRM1986 | 22:7f81fca01f02 | 46 | @param when true reset food position |
JRM1986 | 22:7f81fca01f02 | 47 | */ |
JRM1986 | 15:4c97fe30f3b7 | 48 | |
JRM1986 | 17:94dd8a691d4a | 49 | void set_food_position(int set_frames, int number_frames, bool collision); |
JRM1986 | 22:7f81fca01f02 | 50 | |
JRM1986 | 22:7f81fca01f02 | 51 | /** @return returns food position */ |
JRM1986 | 22:7f81fca01f02 | 52 | |
JRM1986 | 15:4c97fe30f3b7 | 53 | Vector2D get_food_position(); |
JRM1986 | 2:ea90cec2489a | 54 | |
JRM1986 | 2:ea90cec2489a | 55 | private: |
JRM1986 | 2:ea90cec2489a | 56 | |
JRM1986 | 3:50f01159c61d | 57 | int _x; |
JRM1986 | 3:50f01159c61d | 58 | int _y; |
JRM1986 | 21:63c5590cb2c2 | 59 | int _number_frames; |
JRM1986 | 2:ea90cec2489a | 60 | |
JRM1986 | 2:ea90cec2489a | 61 | }; |
JRM1986 | 2:ea90cec2489a | 62 | #endif |