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.
Graphics/Graphics.h
- Committer:
- HenryWTriff
- Date:
- 2020-03-28
- Revision:
- 17:4c5f25d5c4d5
- Parent:
- 11:7b12992156de
- Child:
- 18:5fcb0514fb70
File content as of revision 17:4c5f25d5c4d5:
#ifndef GRAPHICS_H
#define GRAPHICS_H
#include "mbed.h"
#include "Gamepad.h"
#include "N5110.h"
#include "FXOS8700CQ.h"
#include "Graphics.h"
#include "Mechanics.h"
#include "Menu.h"
#include "LEDs.h"
#include "Ghost.h"
#include <string>
/** Graphics Class
* @brief Creates all game graphics.
* @author Henry W Triff
* @date Mar, 2020
*/
#ifndef STRUCTS
#define STRUCTS
//STRUCTS
struct Point_2D {
float x;
float y;
};
struct Line_2D {
Point_2D from;
Point_2D to;
};
struct Square_2D {
Point_2D TL;
Point_2D BR;
};
struct Triangle_2D {
Point_2D TL;
Point_2D BR;
int Type;
};
struct Map_Data {
int number_of_track_lines;
int number_of_dotted_lines;
int number_of_flags;
int number_of_walls;
int number_of_off_track_squares;
int number_of_off_track_triangles;
int number_of_out_of_bounds_squares;
int number_of_out_of_bounds_triangles;
int number_of_gates;
int number_of_boost_plates;
};
struct Time {
int mins;
int secs;
int milis;
};
struct Gyro_Data {
float ax;
float ay;
float az;
float mx;
float my;
float mz;
};
#endif
class Graphics
{
public:
/** Constructor */
Graphics();
/** Destructor */
~Graphics();
//SCREEN SETTINGS
void Change_Contrast(N5110 &LCD, Gamepad &Device);
//GRAPHICS
void Draw_Map(
Point_2D translation,
int angle,
float squish,
Line_2D *Track_Lines,
Line_2D *Track_Dotted_Lines,
Line_2D *Track_Walls,
Point_2D *Track_Flags,
Triangle_2D *Track_Boost_Plates,
Map_Data map_info,
int car_type,
Point_2D ghost_position,
N5110 &LCD
);
void Draw_Laps(int laps, N5110 &LCD);
void Draw_Time(bool finished, Time time, N5110 &LCD);
void Start_Sequence(int state, N5110 &LCD);
void Finish(N5110 &LCD);
void Draw_Logo(N5110 &LCD);
private:
//TRANSFORM
Point_2D Rotate_Point(Point_2D point, float angle);
Point_2D Translate_Point(Point_2D point, int translate_x, int translate_y);
Point_2D Squish_Point(Point_2D point, float squish);
//MATH
int Round(float number);
float Gradient(Point_2D from, Point_2D to);
bool Gradient_Check_Infinate(Point_2D from, Point_2D to);
//DRAW
void Graphics_Draw_Line(Point_2D from, Point_2D to, bool solid, N5110 &LCD);
void Graphics_Draw_Wall(Point_2D from, Point_2D to, int height, N5110 &LCD);
void Graphics_Draw_Boost_Plate(Triangle_2D boost_plate, Point_2D translation, int angle, float squish, N5110 &LCD);
void Graphics_Draw_Sprite(Point_2D point, int x_size, int y_size, int *sprite, N5110 &LCD);
};
#endif