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
- Committer:
- batJoro
- Date:
- 2019-05-10
- Revision:
- 10:b939edd9b87c
- Parent:
- 9:dc13042b09f5
- Child:
- 11:0e6a221ad8a9
File content as of revision 10:b939edd9b87c:
#ifndef ENGINE_H
#define ENGINE_H
#include "mbed.h"
#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:
Engine();
~Engine();
void init(int screenHeight, int screenWidth, int speed);
void read_input(Gamepad &pad, float elapsedTime);
void update(Gamepad &pad, N5110 &lcd, float elapsedTime);
void draw(N5110 &lcd);
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; // fields: curvature distance
int _screen_height;
int _screen_width;
int _lap;
float _track_curvature;
float _track_distance;
float _lap_time;
};
#endif