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 FATFileSystem
GolfEngine/GolfEngine.h@14:08ac9aaa34c3, 2019-05-08 (annotated)
- Committer:
- ellisbhastroud
- Date:
- Wed May 08 14:54:19 2019 +0000
- Revision:
- 14:08ac9aaa34c3
- Parent:
- 13:681192091568
- Child:
- 16:c8d68cbd1ae2
Doxygen comments added;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| ellisbhastroud | 5:0b31909caf7f | 1 | #ifndef GOLFENGINE_H |
| ellisbhastroud | 5:0b31909caf7f | 2 | #define GOLFENGINE_H |
| ellisbhastroud | 5:0b31909caf7f | 3 | |
| ellisbhastroud | 5:0b31909caf7f | 4 | #include "mbed.h" |
| ellisbhastroud | 5:0b31909caf7f | 5 | #include "N5110.h" |
| ellisbhastroud | 13:681192091568 | 6 | #include "SDFileSystem.h" |
| ellisbhastroud | 5:0b31909caf7f | 7 | #include "Gamepad.h" |
| ellisbhastroud | 5:0b31909caf7f | 8 | #include "Ball.h" |
| ellisbhastroud | 5:0b31909caf7f | 9 | |
| ellisbhastroud | 8:d410856c6d04 | 10 | |
| ellisbhastroud | 5:0b31909caf7f | 11 | /** Golf Engine Class |
| ellisbhastroud | 5:0b31909caf7f | 12 | * @brief Library to run golf game |
| ellisbhastroud | 5:0b31909caf7f | 13 | * @author Ellis Blackford Stroud |
| ellisbhastroud | 5:0b31909caf7f | 14 | * @date May, 2018 |
| ellisbhastroud | 5:0b31909caf7f | 15 | */ |
| ellisbhastroud | 5:0b31909caf7f | 16 | |
| ellisbhastroud | 5:0b31909caf7f | 17 | class GolfEngine |
| ellisbhastroud | 5:0b31909caf7f | 18 | { |
| ellisbhastroud | 5:0b31909caf7f | 19 | |
| ellisbhastroud | 5:0b31909caf7f | 20 | public: |
| ellisbhastroud | 5:0b31909caf7f | 21 | |
| ellisbhastroud | 5:0b31909caf7f | 22 | /** Constructor */ |
| ellisbhastroud | 5:0b31909caf7f | 23 | GolfEngine(); |
| ellisbhastroud | 5:0b31909caf7f | 24 | |
| ellisbhastroud | 5:0b31909caf7f | 25 | /** Destructor */ |
| ellisbhastroud | 5:0b31909caf7f | 26 | ~GolfEngine(); |
| ellisbhastroud | 5:0b31909caf7f | 27 | |
| ellisbhastroud | 14:08ac9aaa34c3 | 28 | /** Sets values for new game |
| ellisbhastroud | 14:08ac9aaa34c3 | 29 | * @param the frame rate in Hz |
| ellisbhastroud | 14:08ac9aaa34c3 | 30 | */ |
| ellisbhastroud | 10:9f54a6366e94 | 31 | void init(int frame_rate); |
| ellisbhastroud | 14:08ac9aaa34c3 | 32 | |
| ellisbhastroud | 14:08ac9aaa34c3 | 33 | /** Draws game screen |
| ellisbhastroud | 14:08ac9aaa34c3 | 34 | * @param the class used to interact with the lcd display |
| ellisbhastroud | 14:08ac9aaa34c3 | 35 | */ |
| ellisbhastroud | 14:08ac9aaa34c3 | 36 | void drawGame(N5110 &lcd); |
| ellisbhastroud | 5:0b31909caf7f | 37 | |
| ellisbhastroud | 14:08ac9aaa34c3 | 38 | /** Reads input from gamepad |
| ellisbhastroud | 14:08ac9aaa34c3 | 39 | * @param the class used to interact with the gamepad |
| ellisbhastroud | 14:08ac9aaa34c3 | 40 | */ |
| ellisbhastroud | 8:d410856c6d04 | 41 | void read_input(Gamepad &pad); |
| ellisbhastroud | 5:0b31909caf7f | 42 | |
| ellisbhastroud | 14:08ac9aaa34c3 | 43 | /** Updates ball position according to input |
| ellisbhastroud | 14:08ac9aaa34c3 | 44 | * @param the class used to interact with the gamepad |
| ellisbhastroud | 14:08ac9aaa34c3 | 45 | */ |
| ellisbhastroud | 14:08ac9aaa34c3 | 46 | void update_ball(Gamepad &pad, N5110 &lcd); |
| ellisbhastroud | 14:08ac9aaa34c3 | 47 | |
| ellisbhastroud | 14:08ac9aaa34c3 | 48 | /** Checks if level is over |
| ellisbhastroud | 14:08ac9aaa34c3 | 49 | * @param the class used to interact with the lcd display |
| ellisbhastroud | 14:08ac9aaa34c3 | 50 | * @param the class used to interact with the gamepad |
| ellisbhastroud | 14:08ac9aaa34c3 | 51 | * @param the class used to interact with the sd card |
| ellisbhastroud | 14:08ac9aaa34c3 | 52 | */ |
| ellisbhastroud | 14:08ac9aaa34c3 | 53 | void check_end_level(N5110 &lcd, Gamepad &pad, SDFileSystem &sd); |
| ellisbhastroud | 9:bc34f2243e43 | 54 | |
| ellisbhastroud | 14:08ac9aaa34c3 | 55 | /** Prints current level |
| ellisbhastroud | 14:08ac9aaa34c3 | 56 | * @param the class used to interact with the lcd display |
| ellisbhastroud | 14:08ac9aaa34c3 | 57 | */ |
| ellisbhastroud | 14:08ac9aaa34c3 | 58 | void printLevel(N5110 &lcd); |
| ellisbhastroud | 13:681192091568 | 59 | |
| ellisbhastroud | 14:08ac9aaa34c3 | 60 | /** Resets game over flag */ |
| ellisbhastroud | 14:08ac9aaa34c3 | 61 | void reset_game_over_flag(); |
| ellisbhastroud | 12:7f7fadb5c106 | 62 | |
| ellisbhastroud | 14:08ac9aaa34c3 | 63 | /** Returns game over flag |
| ellisbhastroud | 14:08ac9aaa34c3 | 64 | * @param true if game over and false if now |
| ellisbhastroud | 14:08ac9aaa34c3 | 65 | */ |
| ellisbhastroud | 14:08ac9aaa34c3 | 66 | bool get_game_over_flag(); |
| ellisbhastroud | 9:bc34f2243e43 | 67 | |
| ellisbhastroud | 5:0b31909caf7f | 68 | private: |
| ellisbhastroud | 5:0b31909caf7f | 69 | |
| ellisbhastroud | 12:7f7fadb5c106 | 70 | void drawCourseWalls(N5110 &lcd, WallMap map[], int size); |
| ellisbhastroud | 12:7f7fadb5c106 | 71 | void drawHole(N5110 &lcd, Coord hole); |
| ellisbhastroud | 13:681192091568 | 72 | void file_append(int value, SDFileSystem &sd); |
| ellisbhastroud | 14:08ac9aaa34c3 | 73 | void new_level(N5110 &lcd, SDFileSystem &sd); |
| ellisbhastroud | 14:08ac9aaa34c3 | 74 | void c_maj(Gamepad &pad); |
| ellisbhastroud | 14:08ac9aaa34c3 | 75 | void g_maj7_flash(Gamepad &pad, N5110 &lcd); |
| ellisbhastroud | 14:08ac9aaa34c3 | 76 | |
| ellisbhastroud | 8:d410856c6d04 | 77 | int _level; |
| ellisbhastroud | 14:08ac9aaa34c3 | 78 | bool _game_over_flag; |
| ellisbhastroud | 8:d410856c6d04 | 79 | float _mag; |
| ellisbhastroud | 8:d410856c6d04 | 80 | Vector2D _joy_coord; |
| ellisbhastroud | 8:d410856c6d04 | 81 | float _angle; |
| ellisbhastroud | 5:0b31909caf7f | 82 | Ball _ball; |
| ellisbhastroud | 12:7f7fadb5c106 | 83 | |
| ellisbhastroud | 5:0b31909caf7f | 84 | }; |
| ellisbhastroud | 5:0b31909caf7f | 85 | |
| ellisbhastroud | 5:0b31909caf7f | 86 | #endif |