Henry Triff / Mbed 2 deprecated ELEC2645_Project_el18ht

Dependencies:   mbed

Graphics/Graphics.h

Committer:
HenryWTriff
Date:
2020-02-22
Revision:
7:2ce6e90f6d47
Parent:
6:5f76dd718dc3
Child:
10:29126a41b1da

File content as of revision 7:2ce6e90f6d47:

#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>

#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;
};

struct Menu_Data {
    int Menu_return;
    bool Back;
};

#endif

class Graphics
{
public:
    //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);

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_Sprite(Point_2D point, int x_size, int y_size, int *sprite, 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);

};

#endif