ELEC2645 (2018/19) / Mbed 2 deprecated el17cd

Dependencies:   mbed

Committer:
el17cd
Date:
Mon Apr 29 14:53:36 2019 +0000
Revision:
35:fe3956825bd8
Parent:
34:5cb9b4d01f5c
Child:
36:6fbafc8bed80
removed breif comment in wrong areas

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el17cd 31:e681177037ef 1 #include "mbed.h"
el17cd 31:e681177037ef 2 #include "N5110.h"
el17cd 31:e681177037ef 3 #ifndef FACE_H
el17cd 31:e681177037ef 4 #define FACE_H
el17cd 31:e681177037ef 5 #include "Face.h"
el17cd 31:e681177037ef 6 #endif
el17cd 31:e681177037ef 7 #ifndef CUBE_H
el17cd 31:e681177037ef 8 #define CUBE_H
el17cd 31:e681177037ef 9 #include "Cube.h"
el17cd 31:e681177037ef 10 #endif
el17cd 31:e681177037ef 11
el17cd 32:9c250eda7f3f 12 /** Face class
el17cd 32:9c250eda7f3f 13 *@brief A class used to instantiate a renderer object, this class provides an interface from the game to the display
el17cd 32:9c250eda7f3f 14 *@author Christopher Doel
el17cd 32:9c250eda7f3f 15 *@date April, 2019
el17cd 32:9c250eda7f3f 16 */
el17cd 31:e681177037ef 17 class Renderer {
el17cd 31:e681177037ef 18 private:
el17cd 31:e681177037ef 19 float fov;
el17cd 31:e681177037ef 20 Cube selectionCube;
el17cd 31:e681177037ef 21 public:
el17cd 31:e681177037ef 22 Renderer();
el17cd 31:e681177037ef 23 void init();
el17cd 35:fe3956825bd8 24 /** Initialises the LCD and sets the field of view
el17cd 33:02c5048b3b3f 25 */
el17cd 31:e681177037ef 26 float xTo2D(float x, float z);
el17cd 35:fe3956825bd8 27 /** Projects the 3D x coordinate to 2D perspective
el17cd 31:e681177037ef 28 *@param The 3d x coordinate as a float
el17cd 31:e681177037ef 29 *@param The 3d z coordinate as a float
el17cd 31:e681177037ef 30 *@returns The 2D perspective fo the x coordinate
el17cd 31:e681177037ef 31 */
el17cd 31:e681177037ef 32 float yTo2D(float y, float z);
el17cd 35:fe3956825bd8 33 /** Projects the 3D y coordinate to 2D perspective
el17cd 31:e681177037ef 34 *@param The 3d y coordinate as a float
el17cd 31:e681177037ef 35 *@param The 3d z coordinate as a float
el17cd 31:e681177037ef 36 *@returns The 2D perspective of the y coordinate
el17cd 31:e681177037ef 37 */
el17cd 31:e681177037ef 38 void drawHorizon(float angle);
el17cd 35:fe3956825bd8 39 /** Draws the games horizon line
el17cd 31:e681177037ef 40 *@param The angle of the horizon determined by the joystick position
el17cd 31:e681177037ef 41 */
el17cd 31:e681177037ef 42 void drawFace(Face *face, float angle);
el17cd 35:fe3956825bd8 43 /** Draw an individual face
el17cd 31:e681177037ef 44 *@param The face object
el17cd 31:e681177037ef 45 *@param The angle of the face object as a float
el17cd 31:e681177037ef 46 */
el17cd 31:e681177037ef 47 void rasterizeFace(float (&points)[4][3], Face *face);
el17cd 35:fe3956825bd8 48 /** Fill in the face
el17cd 31:e681177037ef 49 *@param The pointer to an array containing the verticies of the face
el17cd 31:e681177037ef 50 *@param The face object
el17cd 31:e681177037ef 51 */
el17cd 33:02c5048b3b3f 52 void drawFillLines(float (&points)[4][3], int diffX2, int stepBottomY,
el17cd 33:02c5048b3b3f 53 int stepTopX, int stepTopY);
el17cd 35:fe3956825bd8 54 /** Draw an individual face
el17cd 31:e681177037ef 55 *@param The pointer to an array containing the verticies of the face
el17cd 31:e681177037ef 56 *@param The integer difference between the top horizontal edge x coordinates
el17cd 31:e681177037ef 57 *@param The integer difference between right vertical edge y coordinates
el17cd 31:e681177037ef 58 *@param The integer difference between bottom horizontal edge x coordinates
el17cd 31:e681177037ef 59 *@param The integer difference between left horizontal edge y coordinates
el17cd 31:e681177037ef 60 */
el17cd 31:e681177037ef 61 void drawFaceOutline(float (&points)[4][3]);
el17cd 35:fe3956825bd8 62 /** Draw the outline of the face
el17cd 31:e681177037ef 63 *@param The pointer to an array containing the verticies of the face
el17cd 31:e681177037ef 64 */
el17cd 31:e681177037ef 65 void drawAllFaces(Face *faceArray, int noOfFaces, float angle);
el17cd 35:fe3956825bd8 66 /** Draw all faces within a face array
el17cd 31:e681177037ef 67 *@param The pointer to an array of face objects
el17cd 31:e681177037ef 68 *@param The number of faces as an integer
el17cd 31:e681177037ef 69 *@param The angle of the faces as a float
el17cd 31:e681177037ef 70 */
el17cd 31:e681177037ef 71 bool checkOnScreen(float (&Points)[4][3]);
el17cd 35:fe3956825bd8 72 /** Checks whether any area of the face is on the screen
el17cd 31:e681177037ef 73 *@param The pointer to an array containing the verticies of the face
el17cd 31:e681177037ef 74 */
el17cd 31:e681177037ef 75 void print(const char *text, int x, int y);
el17cd 35:fe3956825bd8 76 /** Prints a string at a desired location on the screen
el17cd 31:e681177037ef 77 *@param The pointer to an array of characters of the string
el17cd 31:e681177037ef 78 *@param The x coordinate to draw the string as an integer
el17cd 31:e681177037ef 79 *@param The y coordinate to draw the string as an integer
el17cd 31:e681177037ef 80 */
el17cd 31:e681177037ef 81 void printScore(int score, int x, int y);
el17cd 35:fe3956825bd8 82 /** Prints a score at a desired location on the screen
el17cd 31:e681177037ef 83 *@param The value of the score as an integer
el17cd 31:e681177037ef 84 *@param The x coordinate to draw the score as an integer
el17cd 31:e681177037ef 85 *@param The y coordinate to draw the score as an integer
el17cd 31:e681177037ef 86 */
el17cd 31:e681177037ef 87 void clear();
el17cd 35:fe3956825bd8 88 /** Clears the display
el17cd 31:e681177037ef 89 */
el17cd 31:e681177037ef 90 void refresh();
el17cd 35:fe3956825bd8 91 /** Refreshes the display
el17cd 31:e681177037ef 92 */
el17cd 31:e681177037ef 93 void turnOff();
el17cd 35:fe3956825bd8 94 /** Turns off the display
el17cd 31:e681177037ef 95 */
el17cd 31:e681177037ef 96 void drawDeathScreen(int selection, int highScore);
el17cd 35:fe3956825bd8 97 /** Draws the screen after the user has collided with a cube
el17cd 31:e681177037ef 98 *@param The selected option as an integer
el17cd 31:e681177037ef 99 *@param The high score as an integer
el17cd 31:e681177037ef 100 */
el17cd 31:e681177037ef 101 void drawDeathButtons();
el17cd 35:fe3956825bd8 102 /** Draws the death menus buttons
el17cd 31:e681177037ef 103 */
el17cd 31:e681177037ef 104 void drawHomeScreen(int selection);
el17cd 35:fe3956825bd8 105 /** Draws the games home screen
el17cd 31:e681177037ef 106 *@param The selected option as an integer
el17cd 31:e681177037ef 107 */
el17cd 31:e681177037ef 108 void drawHomeButtons();
el17cd 35:fe3956825bd8 109 /** Draws the home menus buttons
el17cd 31:e681177037ef 110 */
el17cd 31:e681177037ef 111 void drawSelectionCube(int x, int y, int z, int rotationSpeed);
el17cd 35:fe3956825bd8 112 /** Draws the cube which indicates the selected button on the menus
el17cd 31:e681177037ef 113 *@param The x coordinate of where to draw the cube as an integer
el17cd 31:e681177037ef 114 *@param The y coordinate of where to draw the cube as an integer
el17cd 31:e681177037ef 115 *@param The z coordinate of where to draw the cube as an integer
el17cd 31:e681177037ef 116 *@param The rotation speed multiplier of the cube as an integer
el17cd 31:e681177037ef 117 */
el17cd 31:e681177037ef 118 void drawHelpScreen1();
el17cd 35:fe3956825bd8 119 /** Draws the first help screen
el17cd 31:e681177037ef 120 */
el17cd 31:e681177037ef 121 void drawHelpScreen2();
el17cd 35:fe3956825bd8 122 /** Draws the second help screen
el17cd 31:e681177037ef 123 */
el17cd 31:e681177037ef 124 void drawHelpScreen3();
el17cd 35:fe3956825bd8 125 /** Draws the third help screen
el17cd 31:e681177037ef 126 */
el17cd 31:e681177037ef 127 void drawHelpScreen4();
el17cd 35:fe3956825bd8 128 /** Draws the fourth help screen
el17cd 31:e681177037ef 129 */
el17cd 31:e681177037ef 130 };
el17cd 31:e681177037ef 131