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
SnakeTail/SnakeTail.h@13:4fa0d5148216, 2020-05-24 (annotated)
- Committer:
- sdlashmar
- Date:
- Sun May 24 15:08:31 2020 +0000
- Revision:
- 13:4fa0d5148216
- Parent:
- 11:c4b740a970f8
MOUSE X AND Y COORDS WORKING PROPERLY
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| sdlashmar | 5:256e5e0b6cd7 | 1 | #ifndef SNAKETAIL_H |
| sdlashmar | 5:256e5e0b6cd7 | 2 | #define SNAKETAIL_H |
| sdlashmar | 5:256e5e0b6cd7 | 3 | |
| sdlashmar | 5:256e5e0b6cd7 | 4 | #include "mbed.h" |
| sdlashmar | 5:256e5e0b6cd7 | 5 | #include "Gamepad.h" |
| sdlashmar | 5:256e5e0b6cd7 | 6 | #include "N5110.h" |
| sdlashmar | 7:c67a5c6a874f | 7 | #include "SnakeHead.h" |
| sdlashmar | 5:256e5e0b6cd7 | 8 | |
| sdlashmar | 13:4fa0d5148216 | 9 | /** Snake Tail class |
| sdlashmar | 13:4fa0d5148216 | 10 | @brief Class to update and draw the tail of the snake |
| sdlashmar | 13:4fa0d5148216 | 11 | @author Samuel D Lashmar |
| sdlashmar | 13:4fa0d5148216 | 12 | @date May 2020 |
| sdlashmar | 13:4fa0d5148216 | 13 | */ |
| sdlashmar | 13:4fa0d5148216 | 14 | |
| sdlashmar | 5:256e5e0b6cd7 | 15 | class SnakeTail |
| sdlashmar | 5:256e5e0b6cd7 | 16 | |
| sdlashmar | 5:256e5e0b6cd7 | 17 | { |
| sdlashmar | 5:256e5e0b6cd7 | 18 | |
| sdlashmar | 5:256e5e0b6cd7 | 19 | public: |
| sdlashmar | 13:4fa0d5148216 | 20 | /** Constructor */ |
| sdlashmar | 5:256e5e0b6cd7 | 21 | SnakeTail(); |
| sdlashmar | 13:4fa0d5148216 | 22 | /** Destructor */ |
| sdlashmar | 5:256e5e0b6cd7 | 23 | ~SnakeTail(); |
| sdlashmar | 13:4fa0d5148216 | 24 | /** updates the position of all the tail sgements |
| sdlashmar | 13:4fa0d5148216 | 25 | @param 2D vector of previous head coordinates |
| sdlashmar | 13:4fa0d5148216 | 26 | @param length of the tail |
| sdlashmar | 13:4fa0d5148216 | 27 | */ |
| sdlashmar | 7:c67a5c6a874f | 28 | void update(Vector2D headPos, int length); |
| sdlashmar | 13:4fa0d5148216 | 29 | /** draws the tail on the LCD screen |
| sdlashmar | 13:4fa0d5148216 | 30 | @param length of the tail |
| sdlashmar | 13:4fa0d5148216 | 31 | */ |
| sdlashmar | 7:c67a5c6a874f | 32 | void draw(N5110 &lcd, int length); |
| sdlashmar | 5:256e5e0b6cd7 | 33 | |
| sdlashmar | 5:256e5e0b6cd7 | 34 | |
| sdlashmar | 5:256e5e0b6cd7 | 35 | private: |
| sdlashmar | 13:4fa0d5148216 | 36 | //two 100 element arrays for storing the x and y coordinates of the tail segments |
| sdlashmar | 11:c4b740a970f8 | 37 | int tailX[100]; |
| sdlashmar | 11:c4b740a970f8 | 38 | int tailY[100]; |
| sdlashmar | 11:c4b740a970f8 | 39 | int _x_init, _y_init, prevX, prevY, prev2X, prev2Y, _length; |
| sdlashmar | 5:256e5e0b6cd7 | 40 | }; |
| sdlashmar | 5:256e5e0b6cd7 | 41 | |
| sdlashmar | 5:256e5e0b6cd7 | 42 | #endif |
| sdlashmar | 5:256e5e0b6cd7 | 43 |