ELEC2645 (2018/19) / Mbed 2 deprecated el17cd

Dependencies:   mbed

Renderer/Renderer.h

Committer:
el17cd
Date:
2019-04-29
Revision:
33:02c5048b3b3f
Parent:
32:9c250eda7f3f
Child:
34:5cb9b4d01f5c

File content as of revision 33:02c5048b3b3f:

#include "mbed.h"
#include "N5110.h"
#ifndef FACE_H
#define FACE_H
#include "Face.h"
#endif
#ifndef CUBE_H
#define CUBE_H
#include "Cube.h"
#endif

/** Face class
*@brief A class used to instantiate a renderer object, this class provides an interface from the game to the display
*@author Christopher Doel
*@date April, 2019
*/
class Renderer {
  private:
    float fov;
    Cube selectionCube;
  public:
    Renderer();
    void init();
    /** @brief Initialises the LCD and sets the field of view
    */
    float xTo2D(float x, float z);
    /** @brief Projects the 3D x coordinate to 2D perspective
    *@param The 3d x coordinate as a float
    *@param The 3d z coordinate as a float
    *@returns The 2D perspective fo the x coordinate
    */
    float yTo2D(float y, float z);
    /** @brief Projects the 3D y coordinate to 2D perspective
    *@param The 3d y coordinate as a float
    *@param The 3d z coordinate as a float
    *@returns The 2D perspective of the y coordinate
    */
    void drawHorizon(float angle);
    /** @brief Draws the games horizon line
    *@param The angle of the horizon determined by the joystick position
    */
    void drawFace(Face *face, float angle);
    /** @brief Draw an individual face
    *@param The face object
    *@param The angle of the face object as a float
    */
    void rasterizeFace(float (&points)[4][3], Face *face);
    /** @brief Fill in the face
    *@param The pointer to an array containing the verticies of the face
    *@param The face object
    */
    void drawFillLines(float (&points)[4][3], int diffX2, int stepBottomY,
    int stepTopX, int stepTopY);
    /** @brief Draw an individual face
    *@param The pointer to an array containing the verticies of the face
    *@param The integer difference between the top horizontal edge x coordinates
    *@param The integer difference between right vertical edge y coordinates
    *@param The integer difference between bottom horizontal edge x coordinates
    *@param The integer difference between left horizontal edge y coordinates
    */
    void drawFaceOutline(float (&points)[4][3]);
    /** @brief Draw the outline of the face
    *@param The pointer to an array containing the verticies of the face
    */
    void drawAllFaces(Face *faceArray, int noOfFaces, float angle);
    /** @brief Draw all faces within a face array
    *@param The pointer to an array of face objects
    *@param The number of faces as an integer
    *@param The angle of the faces as a float
    */
    bool checkOnScreen(float (&Points)[4][3]);
    /** @brief Checks whether any area of the face is on the screen
    *@param The pointer to an array containing the verticies of the face
    */
    void print(const char *text, int x, int y);
    /** @brief Prints a string at a desired location on the screen
    *@param The pointer to an array of characters of the string
    *@param The x coordinate to draw the string as an integer
    *@param The y coordinate to draw the string as an integer
    */
    void printScore(int score, int x, int y);
    /** @brief Prints a score at a desired location on the screen
    *@param The value of the score as an integer
    *@param The x coordinate to draw the score as an integer
    *@param The y coordinate to draw the score as an integer
    */
    void clear();
    /** @brief Clears the display
    */
    void refresh();
    /** @brief Refreshes the display
    */
    void turnOff();
    /** @brief Turns off the display
    */
    void drawDeathScreen(int selection, int highScore);
    /** @brief Draws the screen after the user has collided with a cube
    *@param The selected option as an integer
    *@param The high score as an integer
    */
    void drawDeathButtons();
    /** @brief Draws the death menus buttons
    */
    void drawHomeScreen(int selection);
    /** @brief Draws the games home screen
    *@param The selected option as an integer
    */
    void drawHomeButtons();
    /** @brief Draws the home menus buttons
    */
    void drawSelectionCube(int x, int y, int z, int rotationSpeed);
    /** @brief Draws the cube which indicates the selected button on the menus
    *@param The x coordinate of where to draw the cube as an integer
    *@param The y coordinate of where to draw the cube as an integer
    *@param The z coordinate of where to draw the cube as an integer
    *@param The rotation speed multiplier of the cube as an integer
    */
    void drawHelpScreen1();
    /** @brief Draws the first help screen
    */
    void drawHelpScreen2();
    /** @brief Draws the second help screen
    */
    void drawHelpScreen3();
    /** @brief Draws the third help screen
    */
    void drawHelpScreen4();
    /** @brief Draws the fourth help screen
    */
};