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
Diff: GameEngine/engine.h
- Revision:
- 10:b939edd9b87c
- Parent:
- 9:dc13042b09f5
- Child:
- 11:0e6a221ad8a9
--- a/GameEngine/engine.h Sun May 05 23:31:07 2019 +0000
+++ b/GameEngine/engine.h Fri May 10 12:00:30 2019 +0000
@@ -6,13 +6,17 @@
#include "N5110.h"
#include "Gamepad.h"
#include "functions.h"
+#include "car.h"
+#include "map.h"
#include <vector>
+
struct MapSegment {
float curvature;
float meters;
};
+
class Engine{
public:
@@ -20,27 +24,43 @@
~Engine();
void init(int screenHeight, int screenWidth, int speed);
- void read_input(Gamepad &pad);
+ void read_input(Gamepad &pad, float elapsedTime);
void update(Gamepad &pad, N5110 &lcd, float elapsedTime);
void draw(N5110 &lcd);
- void setSpeed(int speed);
+ void addSegment(float curvature, float meters);
+ void calc_track_distance();
+
+ void assignPixel(N5110 &lcd, int x, int y, int row,
+ float SideColour,
+ float GrassColour,
+ int leftGrass,
+ int rightGrass,
+ int leftSide,
+ int rightSide);
+
+ float defineStripes(N5110 &lcd, Car &car, float frequency, float perspective);
+ int get_lap();
+ float get_lap_time();
private:
+ Car car;
+ Map map;
+
float _curvature;
- vector<MapSegment> track; // curvature and distance
-
- float _car_positon;
- float _distance;
- float _speed;
+ vector<MapSegment> track; // fields: curvature distance
+
int _screen_height;
int _screen_width;
+ int _lap;
- static int car1[];
- static int car2[];
- static int car3[];
+ float _track_curvature;
+ float _track_distance;
+
+ float _lap_time;
+
};
#endif
\ No newline at end of file