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
Renderer/Renderer.h
- Committer:
- el17cd
- Date:
- 2019-04-05
- Revision:
- 31:e681177037ef
- Child:
- 32:9c250eda7f3f
File content as of revision 31:e681177037ef:
#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 class Renderer { private: float fov; Cube selectionCube; public: Renderer(); void init(); 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 */ };