Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
SnakeEngine/SnakeEngine.h@7:24a3f13ce36d, 2020-05-31 (annotated)
- Committer:
- el18lg
- Date:
- Sun May 31 14:12:45 2020 +0000
- Revision:
- 7:24a3f13ce36d
- Parent:
- 6:266fb8fc17f4
- Child:
- 8:59b01b57f0da
When snake eats food, food now relocates in a different position and snake body increase by one;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| el18lg | 3:beb0cc405b1e | 1 | #ifndef SNAKEENGINE_H |
| el18lg | 3:beb0cc405b1e | 2 | #define SNAKEENGINE_H |
| el18lg | 3:beb0cc405b1e | 3 | |
| el18lg | 3:beb0cc405b1e | 4 | #include "mbed.h" |
| el18lg | 3:beb0cc405b1e | 5 | #include "N5110.h" |
| el18lg | 3:beb0cc405b1e | 6 | #include "Gamepad.h" |
| el18lg | 3:beb0cc405b1e | 7 | #include "Head.h" |
| el18lg | 5:e0f08e8022de | 8 | #include "Body.h" |
| el18lg | 6:266fb8fc17f4 | 9 | #include "Food.h" |
| el18lg | 3:beb0cc405b1e | 10 | |
| el18lg | 3:beb0cc405b1e | 11 | // gap from edge of screen |
| el18lg | 3:beb0cc405b1e | 12 | #define GAP 2 |
| el18lg | 3:beb0cc405b1e | 13 | |
| el18lg | 3:beb0cc405b1e | 14 | class SnakeEngine |
| el18lg | 3:beb0cc405b1e | 15 | { |
| el18lg | 3:beb0cc405b1e | 16 | |
| el18lg | 3:beb0cc405b1e | 17 | public: |
| el18lg | 3:beb0cc405b1e | 18 | SnakeEngine(); |
| el18lg | 3:beb0cc405b1e | 19 | ~SnakeEngine(); |
| el18lg | 3:beb0cc405b1e | 20 | |
| el18lg | 7:24a3f13ce36d | 21 | void init(int head_length,int head_speed, int _food_size); |
| el18lg | 3:beb0cc405b1e | 22 | void read_input(Gamepad &pad); |
| el18lg | 7:24a3f13ce36d | 23 | |
| el18lg | 6:266fb8fc17f4 | 24 | void update(Gamepad &pad, N5110 &lcd); |
| el18lg | 3:beb0cc405b1e | 25 | void draw(N5110 &lcd); |
| el18lg | 7:24a3f13ce36d | 26 | |
| el18lg | 3:beb0cc405b1e | 27 | private: |
| el18lg | 4:748b3e0062f6 | 28 | int hx; |
| el18lg | 7:24a3f13ce36d | 29 | int hy; |
| el18lg | 7:24a3f13ce36d | 30 | int fx; |
| el18lg | 7:24a3f13ce36d | 31 | int fy; |
| el18lg | 3:beb0cc405b1e | 32 | int _head_length; |
| el18lg | 3:beb0cc405b1e | 33 | int _head_speed; |
| el18lg | 7:24a3f13ce36d | 34 | int score; |
| el18lg | 5:e0f08e8022de | 35 | int _nbody; |
| el18lg | 7:24a3f13ce36d | 36 | int _food_size; |
| el18lg | 7:24a3f13ce36d | 37 | void eat_food(Gamepad &pad); |
| el18lg | 7:24a3f13ce36d | 38 | void collison |
| el18lg | 3:beb0cc405b1e | 39 | Head _h; |
| el18lg | 5:e0f08e8022de | 40 | Body _b; |
| el18lg | 6:266fb8fc17f4 | 41 | Food _f; |
| el18lg | 3:beb0cc405b1e | 42 | Direction _d; |
| el18lg | 4:748b3e0062f6 | 43 | float _mag; |
| el18lg | 4:748b3e0062f6 | 44 | |
| el18lg | 3:beb0cc405b1e | 45 | |
| el18lg | 3:beb0cc405b1e | 46 | }; |
| el18lg | 3:beb0cc405b1e | 47 | |
| el18lg | 3:beb0cc405b1e | 48 | #endif |