![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
demo
Dependencies: mbed Gamepad N5110
foods/foods.h@0:ba32cfe0051e, 2020-05-14 (annotated)
- Committer:
- Ting12138
- Date:
- Thu May 14 12:57:32 2020 +0000
- Revision:
- 0:ba32cfe0051e
demo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Ting12138 | 0:ba32cfe0051e | 1 | #ifndef FOODS_H |
Ting12138 | 0:ba32cfe0051e | 2 | #define FOODS_H |
Ting12138 | 0:ba32cfe0051e | 3 | |
Ting12138 | 0:ba32cfe0051e | 4 | #include "mbed.h" |
Ting12138 | 0:ba32cfe0051e | 5 | #include "N5110.h" |
Ting12138 | 0:ba32cfe0051e | 6 | #include "Gamepad.h" |
Ting12138 | 0:ba32cfe0051e | 7 | |
Ting12138 | 0:ba32cfe0051e | 8 | class foods |
Ting12138 | 0:ba32cfe0051e | 9 | { |
Ting12138 | 0:ba32cfe0051e | 10 | |
Ting12138 | 0:ba32cfe0051e | 11 | public: |
Ting12138 | 0:ba32cfe0051e | 12 | foods(); |
Ting12138 | 0:ba32cfe0051e | 13 | ~foods(); |
Ting12138 | 0:ba32cfe0051e | 14 | |
Ting12138 | 0:ba32cfe0051e | 15 | void init(int x,int size,int velocity); |
Ting12138 | 0:ba32cfe0051e | 16 | /** |
Ting12138 | 0:ba32cfe0051e | 17 | * @param N5110 @details LCD screen |
Ting12138 | 0:ba32cfe0051e | 18 | * @brief Displays food on screen |
Ting12138 | 0:ba32cfe0051e | 19 | */ |
Ting12138 | 0:ba32cfe0051e | 20 | void draw(N5110 &lcd); |
Ting12138 | 0:ba32cfe0051e | 21 | // accessors and mutators |
Ting12138 | 0:ba32cfe0051e | 22 | /** |
Ting12138 | 0:ba32cfe0051e | 23 | * @returns The new coordinate of foods |
Ting12138 | 0:ba32cfe0051e | 24 | * @brief Updates the position of foods |
Ting12138 | 0:ba32cfe0051e | 25 | */ |
Ting12138 | 0:ba32cfe0051e | 26 | void update(); |
Ting12138 | 0:ba32cfe0051e | 27 | /** |
Ting12138 | 0:ba32cfe0051e | 28 | * @returns The new coordinate of foods |
Ting12138 | 0:ba32cfe0051e | 29 | * @brief Resets the position of foods |
Ting12138 | 0:ba32cfe0051e | 30 | */ |
Ting12138 | 0:ba32cfe0051e | 31 | void replace(); |
Ting12138 | 0:ba32cfe0051e | 32 | /** |
Ting12138 | 0:ba32cfe0051e | 33 | * @returns The coordinate of foods |
Ting12138 | 0:ba32cfe0051e | 34 | * @brief Retrieves the position of foods |
Ting12138 | 0:ba32cfe0051e | 35 | */ |
Ting12138 | 0:ba32cfe0051e | 36 | Vector2D get_pos(); |
Ting12138 | 0:ba32cfe0051e | 37 | |
Ting12138 | 0:ba32cfe0051e | 38 | private: |
Ting12138 | 0:ba32cfe0051e | 39 | |
Ting12138 | 0:ba32cfe0051e | 40 | int _size; // the radius of the foods |
Ting12138 | 0:ba32cfe0051e | 41 | int _x; |
Ting12138 | 0:ba32cfe0051e | 42 | int _y; |
Ting12138 | 0:ba32cfe0051e | 43 | int _velocity; |
Ting12138 | 0:ba32cfe0051e | 44 | }; |
Ting12138 | 0:ba32cfe0051e | 45 | #endif |