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
Frogger/Frogger.h@37:65c9e5a65738, 2020-05-17 (annotated)
- Committer:
- el19tb
- Date:
- Sun May 17 23:20:23 2020 +0000
- Revision:
- 37:65c9e5a65738
- Parent:
- 29:2151cd327a36
- Child:
- 42:04e326dcf09b
fadded global variables, changed construction of the engine, made the engine more structure
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el19tb | 29:2151cd327a36 | 1 | #ifndef FROGGER_H |
el19tb | 29:2151cd327a36 | 2 | #define FROGGER_H |
el19tb | 3:648c9d5001be | 3 | |
el19tb | 2:86cef2afa648 | 4 | #include "mbed.h" |
el19tb | 2:86cef2afa648 | 5 | #include "N5110.h" |
el19tb | 2:86cef2afa648 | 6 | #include "Gamepad.h" |
el19tb | 29:2151cd327a36 | 7 | #include "Frog.h" |
el19tb | 29:2151cd327a36 | 8 | #include "WaterObject.h" |
el19tb | 11:cc5861abfca5 | 9 | #include "Level.h" |
el19tb | 13:cd6d2f999057 | 10 | |
el19tb | 4:aae7f8d4ab78 | 11 | #include <vector> |
el19tb | 2:86cef2afa648 | 12 | |
el19tb | 17:67dbdfcdcec2 | 13 | struct Water |
el19tb | 15:b15bf9357cd9 | 14 | { |
el19tb | 19:6d9721ffc078 | 15 | int x; |
el19tb | 15:b15bf9357cd9 | 16 | int row; |
el19tb | 19:6d9721ffc078 | 17 | char c; |
el19tb | 17:67dbdfcdcec2 | 18 | float speed; |
el19tb | 19:6d9721ffc078 | 19 | }; |
el19tb | 19:6d9721ffc078 | 20 | |
el19tb | 19:6d9721ffc078 | 21 | struct Safety |
el19tb | 19:6d9721ffc078 | 22 | { |
el19tb | 17:67dbdfcdcec2 | 23 | int x; |
el19tb | 19:6d9721ffc078 | 24 | int row; |
el19tb | 19:6d9721ffc078 | 25 | char c; |
el19tb | 19:6d9721ffc078 | 26 | }; |
el19tb | 15:b15bf9357cd9 | 27 | |
el19tb | 29:2151cd327a36 | 28 | class Frogger |
el19tb | 29:2151cd327a36 | 29 | { |
el19tb | 11:cc5861abfca5 | 30 | public: |
el19tb | 29:2151cd327a36 | 31 | |
el19tb | 29:2151cd327a36 | 32 | GraphicEngine *graphics; // local renderer object |
el19tb | 37:65c9e5a65738 | 33 | Level *levelptr; // local level object |
el19tb | 29:2151cd327a36 | 34 | Frog *frog; |
el19tb | 37:65c9e5a65738 | 35 | int grid; // size of one game unit |
el19tb | 37:65c9e5a65738 | 36 | |
el19tb | 37:65c9e5a65738 | 37 | |
el19tb | 37:65c9e5a65738 | 38 | Frogger(GraphicEngine *engine, Level *levelptr, Frog *frog, int grid, int w, int h); // constructor |
el19tb | 37:65c9e5a65738 | 39 | |
el19tb | 37:65c9e5a65738 | 40 | public: |
el19tb | 37:65c9e5a65738 | 41 | int current_level; |
el19tb | 29:2151cd327a36 | 42 | |
el19tb | 29:2151cd327a36 | 43 | public: |
el19tb | 29:2151cd327a36 | 44 | |
el19tb | 29:2151cd327a36 | 45 | Gamepad gamepad; |
el19tb | 15:b15bf9357cd9 | 46 | int row_number; |
el19tb | 18:6be4c3c94a3d | 47 | int grid_width; // screen width in grid units |
el19tb | 37:65c9e5a65738 | 48 | int lcd_w; |
el19tb | 37:65c9e5a65738 | 49 | int lcd_h; |
el19tb | 17:67dbdfcdcec2 | 50 | |
el19tb | 18:6be4c3c94a3d | 51 | std::vector<Background> roads; |
el19tb | 19:6d9721ffc078 | 52 | std::vector<Safety> safety_lane; |
el19tb | 19:6d9721ffc078 | 53 | std::vector<Water> water; |
el19tb | 29:2151cd327a36 | 54 | int grid; // size of game unit grids in the screen |
el19tb | 11:cc5861abfca5 | 55 | |
el19tb | 2:86cef2afa648 | 56 | public: |
el19tb | 2:86cef2afa648 | 57 | void start(); |
el19tb | 2:86cef2afa648 | 58 | void input(); |
el19tb | 2:86cef2afa648 | 59 | void process_input(); |
el19tb | 2:86cef2afa648 | 60 | void clear(); |
el19tb | 2:86cef2afa648 | 61 | |
el19tb | 2:86cef2afa648 | 62 | void game(); |
el19tb | 2:86cef2afa648 | 63 | void refresh(); |
el19tb | 3:648c9d5001be | 64 | |
el19tb | 3:648c9d5001be | 65 | void moveChicken(int xWay, int yWay); |
el19tb | 3:648c9d5001be | 66 | |
el19tb | 5:6e3afee7eac3 | 67 | void moveCar(Car *car, int dir, int x); |
el19tb | 3:648c9d5001be | 68 | void move(); |
el19tb | 3:648c9d5001be | 69 | |
el19tb | 3:648c9d5001be | 70 | void setup(); |
el19tb | 8:52794de935b2 | 71 | void setCollision(Car* object); |
el19tb | 8:52794de935b2 | 72 | void frogOnLog(Car* car); |
el19tb | 37:65c9e5a65738 | 73 | bool returnCollision(Car* log); |
el19tb | 2:86cef2afa648 | 74 | }; |
el19tb | 2:86cef2afa648 | 75 | |
el19tb | 2:86cef2afa648 | 76 | |
el19tb | 2:86cef2afa648 | 77 | #endif |
el19tb | 2:86cef2afa648 | 78 | |
el19tb | 2:86cef2afa648 | 79 | |
el19tb | 2:86cef2afa648 | 80 |