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@36:6fbafc8bed80, 2019-04-29 (annotated)
- Committer:
- el17cd
- Date:
- Mon Apr 29 14:58:59 2019 +0000
- Revision:
- 36:6fbafc8bed80
- Parent:
- 35:fe3956825bd8
- Child:
- 37:524b91130885
Ensured all doxygen descriptions are above function declarations
Who changed what in which revision?
User | Revision | Line number | New 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 | 35:fe3956825bd8 | 23 | /** Initialises the LCD and sets the field of view |
el17cd | 33:02c5048b3b3f | 24 | */ |
el17cd | 36:6fbafc8bed80 | 25 | void init(); |
el17cd | 35:fe3956825bd8 | 26 | /** Projects the 3D x coordinate to 2D perspective |
el17cd | 31:e681177037ef | 27 | *@param The 3d x coordinate as a float |
el17cd | 31:e681177037ef | 28 | *@param The 3d z coordinate as a float |
el17cd | 31:e681177037ef | 29 | *@returns The 2D perspective fo the x coordinate |
el17cd | 31:e681177037ef | 30 | */ |
el17cd | 36:6fbafc8bed80 | 31 | float xTo2D(float x, float z); |
el17cd | 35:fe3956825bd8 | 32 | /** Projects the 3D y coordinate to 2D perspective |
el17cd | 31:e681177037ef | 33 | *@param The 3d y coordinate as a float |
el17cd | 31:e681177037ef | 34 | *@param The 3d z coordinate as a float |
el17cd | 31:e681177037ef | 35 | *@returns The 2D perspective of the y coordinate |
el17cd | 31:e681177037ef | 36 | */ |
el17cd | 36:6fbafc8bed80 | 37 | float yTo2D(float y, float z); |
el17cd | 35:fe3956825bd8 | 38 | /** Draws the games horizon line |
el17cd | 31:e681177037ef | 39 | *@param The angle of the horizon determined by the joystick position |
el17cd | 31:e681177037ef | 40 | */ |
el17cd | 36:6fbafc8bed80 | 41 | void drawHorizon(float angle); |
el17cd | 36:6fbafc8bed80 | 42 | /** Draw an individual face |
el17cd | 36:6fbafc8bed80 | 43 | *@param The face object |
el17cd | 36:6fbafc8bed80 | 44 | *@param The angle of the face object as a float |
el17cd | 36:6fbafc8bed80 | 45 | */ |
el17cd | 31:e681177037ef | 46 | void drawFace(Face *face, float angle); |
el17cd | 35:fe3956825bd8 | 47 | /** Draw an individual face |
el17cd | 31:e681177037ef | 48 | *@param The face object |
el17cd | 31:e681177037ef | 49 | *@param The angle of the face object as a float |
el17cd | 31:e681177037ef | 50 | */ |
el17cd | 31:e681177037ef | 51 | void rasterizeFace(float (&points)[4][3], Face *face); |
el17cd | 35:fe3956825bd8 | 52 | /** Draw an individual face |
el17cd | 31:e681177037ef | 53 | *@param The pointer to an array containing the verticies of the face |
el17cd | 31:e681177037ef | 54 | *@param The integer difference between the top horizontal edge x coordinates |
el17cd | 31:e681177037ef | 55 | *@param The integer difference between right vertical edge y coordinates |
el17cd | 31:e681177037ef | 56 | *@param The integer difference between bottom horizontal edge x coordinates |
el17cd | 31:e681177037ef | 57 | *@param The integer difference between left horizontal edge y coordinates |
el17cd | 31:e681177037ef | 58 | */ |
el17cd | 36:6fbafc8bed80 | 59 | void drawFillLines(float (&points)[4][3], int diffX2, int stepBottomY, |
el17cd | 36:6fbafc8bed80 | 60 | int stepTopX, int stepTopY); |
el17cd | 35:fe3956825bd8 | 61 | /** Draw the outline of the face |
el17cd | 31:e681177037ef | 62 | *@param The pointer to an array containing the verticies of the face |
el17cd | 31:e681177037ef | 63 | */ |
el17cd | 36:6fbafc8bed80 | 64 | void drawFaceOutline(float (&points)[4][3]); |
el17cd | 35:fe3956825bd8 | 65 | /** Draw all faces within a face array |
el17cd | 31:e681177037ef | 66 | *@param The pointer to an array of face objects |
el17cd | 31:e681177037ef | 67 | *@param The number of faces as an integer |
el17cd | 31:e681177037ef | 68 | *@param The angle of the faces as a float |
el17cd | 31:e681177037ef | 69 | */ |
el17cd | 36:6fbafc8bed80 | 70 | void drawAllFaces(Face *faceArray, int noOfFaces, float angle); |
el17cd | 35:fe3956825bd8 | 71 | /** Checks whether any area of the face is on the screen |
el17cd | 31:e681177037ef | 72 | *@param The pointer to an array containing the verticies of the face |
el17cd | 31:e681177037ef | 73 | */ |
el17cd | 36:6fbafc8bed80 | 74 | bool checkOnScreen(float (&Points)[4][3]); |
el17cd | 35:fe3956825bd8 | 75 | /** Prints a string at a desired location on the screen |
el17cd | 31:e681177037ef | 76 | *@param The pointer to an array of characters of the string |
el17cd | 31:e681177037ef | 77 | *@param The x coordinate to draw the string as an integer |
el17cd | 31:e681177037ef | 78 | *@param The y coordinate to draw the string as an integer |
el17cd | 31:e681177037ef | 79 | */ |
el17cd | 36:6fbafc8bed80 | 80 | void print(const char *text, int x, int y); |
el17cd | 35:fe3956825bd8 | 81 | /** Prints a score at a desired location on the screen |
el17cd | 31:e681177037ef | 82 | *@param The value of the score as an integer |
el17cd | 31:e681177037ef | 83 | *@param The x coordinate to draw the score as an integer |
el17cd | 31:e681177037ef | 84 | *@param The y coordinate to draw the score as an integer |
el17cd | 31:e681177037ef | 85 | */ |
el17cd | 36:6fbafc8bed80 | 86 | void printScore(int score, int x, int y); |
el17cd | 36:6fbafc8bed80 | 87 | /** Clears the display |
el17cd | 36:6fbafc8bed80 | 88 | */ |
el17cd | 31:e681177037ef | 89 | void clear(); |
el17cd | 36:6fbafc8bed80 | 90 | /** Refreshes the display |
el17cd | 31:e681177037ef | 91 | */ |
el17cd | 31:e681177037ef | 92 | void refresh(); |
el17cd | 36:6fbafc8bed80 | 93 | /** Turns off the display |
el17cd | 31:e681177037ef | 94 | */ |
el17cd | 31:e681177037ef | 95 | void turnOff(); |
el17cd | 35:fe3956825bd8 | 96 | /** Draws the screen after the user has collided with a cube |
el17cd | 31:e681177037ef | 97 | *@param The selected option as an integer |
el17cd | 31:e681177037ef | 98 | *@param The high score as an integer |
el17cd | 31:e681177037ef | 99 | */ |
el17cd | 36:6fbafc8bed80 | 100 | void drawDeathScreen(int selection, int highScore); |
el17cd | 35:fe3956825bd8 | 101 | /** Draws the death menus buttons |
el17cd | 31:e681177037ef | 102 | */ |
el17cd | 36:6fbafc8bed80 | 103 | void drawDeathButtons(); |
el17cd | 35:fe3956825bd8 | 104 | /** Draws the games home screen |
el17cd | 31:e681177037ef | 105 | *@param The selected option as an integer |
el17cd | 31:e681177037ef | 106 | */ |
el17cd | 36:6fbafc8bed80 | 107 | void drawHomeScreen(int selection); |
el17cd | 35:fe3956825bd8 | 108 | /** Draws the home menus buttons |
el17cd | 31:e681177037ef | 109 | */ |
el17cd | 36:6fbafc8bed80 | 110 | void drawHomeButtons(); |
el17cd | 35:fe3956825bd8 | 111 | /** Draws the cube which indicates the selected button on the menus |
el17cd | 31:e681177037ef | 112 | *@param The x coordinate of where to draw the cube as an integer |
el17cd | 31:e681177037ef | 113 | *@param The y coordinate of where to draw the cube as an integer |
el17cd | 31:e681177037ef | 114 | *@param The z coordinate of where to draw the cube as an integer |
el17cd | 31:e681177037ef | 115 | *@param The rotation speed multiplier of the cube as an integer |
el17cd | 31:e681177037ef | 116 | */ |
el17cd | 36:6fbafc8bed80 | 117 | void drawSelectionCube(int x, int y, int z, int rotationSpeed); |
el17cd | 35:fe3956825bd8 | 118 | /** Draws the first help screen |
el17cd | 31:e681177037ef | 119 | */ |
el17cd | 36:6fbafc8bed80 | 120 | void drawHelpScreen1(); |
el17cd | 36:6fbafc8bed80 | 121 | /** Draws the second help screen |
el17cd | 36:6fbafc8bed80 | 122 | */ |
el17cd | 31:e681177037ef | 123 | void drawHelpScreen2(); |
el17cd | 36:6fbafc8bed80 | 124 | /** Draws the third help screen |
el17cd | 31:e681177037ef | 125 | */ |
el17cd | 31:e681177037ef | 126 | void drawHelpScreen3(); |
el17cd | 35:fe3956825bd8 | 127 | /** Draws the third help screen |
el17cd | 31:e681177037ef | 128 | */ |
el17cd | 31:e681177037ef | 129 | void drawHelpScreen4(); |
el17cd | 31:e681177037ef | 130 | }; |
el17cd | 31:e681177037ef | 131 |