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-02-11
 - Revision:
 - 5:2d9f3c36bcb9
 - Parent:
 - 3:ceed6d026b8b
 - Child:
 - 6:5f76dd718dc3
 
File content as of revision 5:2d9f3c36bcb9:
#ifndef GRAPHICS_H
#define GRAPHICS_H
#include "mbed.h"
#include "Gamepad.h"
#include "N5110.h"
#include "Graphics.h"
#include "Controls.h"
#include "Mechanics.h"
#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;
};
#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,
        Map_Data map_info,
        N5110 &LCD
    );
    void Draw_Laps(int laps, 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);
};
#endif