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
GameEngine/engine.h@10:b939edd9b87c, 2019-05-10 (annotated)
- Committer:
- batJoro
- Date:
- Fri May 10 12:00:30 2019 +0000
- Revision:
- 10:b939edd9b87c
- Parent:
- 9:dc13042b09f5
- Child:
- 11:0e6a221ad8a9
final;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| batJoro | 6:4c55dd4b6d42 | 1 | |
| batJoro | 6:4c55dd4b6d42 | 2 | #ifndef ENGINE_H |
| batJoro | 6:4c55dd4b6d42 | 3 | #define ENGINE_H |
| batJoro | 6:4c55dd4b6d42 | 4 | |
| batJoro | 8:b3738229ba85 | 5 | #include "mbed.h" |
| batJoro | 8:b3738229ba85 | 6 | #include "N5110.h" |
| batJoro | 8:b3738229ba85 | 7 | #include "Gamepad.h" |
| batJoro | 8:b3738229ba85 | 8 | #include "functions.h" |
| batJoro | 10:b939edd9b87c | 9 | #include "car.h" |
| batJoro | 10:b939edd9b87c | 10 | #include "map.h" |
| batJoro | 9:dc13042b09f5 | 11 | #include <vector> |
| batJoro | 8:b3738229ba85 | 12 | |
| batJoro | 10:b939edd9b87c | 13 | |
| batJoro | 9:dc13042b09f5 | 14 | struct MapSegment { |
| batJoro | 9:dc13042b09f5 | 15 | |
| batJoro | 9:dc13042b09f5 | 16 | float curvature; |
| batJoro | 9:dc13042b09f5 | 17 | float meters; |
| batJoro | 9:dc13042b09f5 | 18 | }; |
| batJoro | 10:b939edd9b87c | 19 | |
| batJoro | 8:b3738229ba85 | 20 | class Engine{ |
| batJoro | 6:4c55dd4b6d42 | 21 | |
| batJoro | 8:b3738229ba85 | 22 | public: |
| batJoro | 8:b3738229ba85 | 23 | Engine(); |
| batJoro | 8:b3738229ba85 | 24 | ~Engine(); |
| batJoro | 8:b3738229ba85 | 25 | |
| batJoro | 8:b3738229ba85 | 26 | void init(int screenHeight, int screenWidth, int speed); |
| batJoro | 10:b939edd9b87c | 27 | void read_input(Gamepad &pad, float elapsedTime); |
| batJoro | 9:dc13042b09f5 | 28 | void update(Gamepad &pad, N5110 &lcd, float elapsedTime); |
| batJoro | 8:b3738229ba85 | 29 | void draw(N5110 &lcd); |
| batJoro | 8:b3738229ba85 | 30 | |
| batJoro | 10:b939edd9b87c | 31 | void addSegment(float curvature, float meters); |
| batJoro | 10:b939edd9b87c | 32 | void calc_track_distance(); |
| batJoro | 10:b939edd9b87c | 33 | |
| batJoro | 10:b939edd9b87c | 34 | void assignPixel(N5110 &lcd, int x, int y, int row, |
| batJoro | 10:b939edd9b87c | 35 | float SideColour, |
| batJoro | 10:b939edd9b87c | 36 | float GrassColour, |
| batJoro | 10:b939edd9b87c | 37 | int leftGrass, |
| batJoro | 10:b939edd9b87c | 38 | int rightGrass, |
| batJoro | 10:b939edd9b87c | 39 | int leftSide, |
| batJoro | 10:b939edd9b87c | 40 | int rightSide); |
| batJoro | 10:b939edd9b87c | 41 | |
| batJoro | 10:b939edd9b87c | 42 | float defineStripes(N5110 &lcd, Car &car, float frequency, float perspective); |
| batJoro | 10:b939edd9b87c | 43 | int get_lap(); |
| batJoro | 10:b939edd9b87c | 44 | float get_lap_time(); |
| batJoro | 8:b3738229ba85 | 45 | |
| batJoro | 8:b3738229ba85 | 46 | private: |
| batJoro | 9:dc13042b09f5 | 47 | |
| batJoro | 10:b939edd9b87c | 48 | Car car; |
| batJoro | 10:b939edd9b87c | 49 | Map map; |
| batJoro | 10:b939edd9b87c | 50 | |
| batJoro | 9:dc13042b09f5 | 51 | float _curvature; |
| batJoro | 9:dc13042b09f5 | 52 | |
| batJoro | 10:b939edd9b87c | 53 | vector<MapSegment> track; // fields: curvature distance |
| batJoro | 10:b939edd9b87c | 54 | |
| batJoro | 8:b3738229ba85 | 55 | int _screen_height; |
| batJoro | 8:b3738229ba85 | 56 | int _screen_width; |
| batJoro | 10:b939edd9b87c | 57 | int _lap; |
| batJoro | 8:b3738229ba85 | 58 | |
| batJoro | 10:b939edd9b87c | 59 | float _track_curvature; |
| batJoro | 10:b939edd9b87c | 60 | float _track_distance; |
| batJoro | 10:b939edd9b87c | 61 | |
| batJoro | 10:b939edd9b87c | 62 | float _lap_time; |
| batJoro | 10:b939edd9b87c | 63 | |
| batJoro | 6:4c55dd4b6d42 | 64 | }; |
| batJoro | 6:4c55dd4b6d42 | 65 | |
| batJoro | 6:4c55dd4b6d42 | 66 | #endif |