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
Cube/Cube.h@23:eb50ab95bb53, 2019-04-03 (annotated)
- Committer:
- el17cd
- Date:
- Wed Apr 03 16:00:50 2019 +0000
- Revision:
- 23:eb50ab95bb53
- Parent:
- 22:236319885874
- Child:
- 25:3995271e411c
Doxygen reported Game.h, amended coding style in Game.cpp
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el17cd | 4:759a5c34e239 | 1 | #include "mbed.h" |
el17cd | 4:759a5c34e239 | 2 | #ifndef FACE_H |
el17cd | 4:759a5c34e239 | 3 | #define FACE_H |
el17cd | 4:759a5c34e239 | 4 | #include "Face.h" |
el17cd | 4:759a5c34e239 | 5 | #endif |
el17cd | 23:eb50ab95bb53 | 6 | /** Cube class |
el17cd | 23:eb50ab95bb53 | 7 | *@brief A class used to instantiate a cube object, this is the obstacle in the game |
el17cd | 23:eb50ab95bb53 | 8 | *@author Christopher Doel |
el17cd | 23:eb50ab95bb53 | 9 | *@date April, 2019 |
el17cd | 23:eb50ab95bb53 | 10 | */ |
el17cd | 4:759a5c34e239 | 11 | class Cube { |
el17cd | 4:759a5c34e239 | 12 | private: |
el17cd | 17:3c9672c6e532 | 13 | float verticies[8][3]; |
el17cd | 4:759a5c34e239 | 14 | Face faces[6]; |
el17cd | 17:3c9672c6e532 | 15 | float xPos, yPos, zPos; |
el17cd | 4:759a5c34e239 | 16 | public: |
el17cd | 23:eb50ab95bb53 | 17 | |
el17cd | 16:64cd7bc094f9 | 18 | Cube(); |
el17cd | 23:eb50ab95bb53 | 19 | /**brief The constructor of the Cube class which instantiates the cube object. |
el17cd | 23:eb50ab95bb53 | 20 | *No parameters are required as the cube is initially created with a size of 5 and a position at the origin. |
el17cd | 23:eb50ab95bb53 | 21 | */ |
el17cd | 16:64cd7bc094f9 | 22 | Face getFace(int index); |
el17cd | 23:eb50ab95bb53 | 23 | /** @brief An accessor method which gets a face of the cube depending on the index provided |
el17cd | 23:eb50ab95bb53 | 24 | *@param The integer index of the face required |
el17cd | 23:eb50ab95bb53 | 25 | *@returns A face object corresponding to the index provided |
el17cd | 23:eb50ab95bb53 | 26 | */ |
el17cd | 22:236319885874 | 27 | void setVisible(); |
el17cd | 23:eb50ab95bb53 | 28 | /** @brief Sets the faces of the cube to be visible so that they will be rendered |
el17cd | 23:eb50ab95bb53 | 29 | */ |
el17cd | 22:236319885874 | 30 | void updateFacesVerticies(float (&vert)[8][3]); |
el17cd | 23:eb50ab95bb53 | 31 | /** @brief sets the verticies of all the cubes faces depending on the location and size of the cube |
el17cd | 23:eb50ab95bb53 | 32 | *@param The memory address of the two dimentional float array which stores all x, y, z coordinates for each 8 verticies |
el17cd | 23:eb50ab95bb53 | 33 | */ |
el17cd | 22:236319885874 | 34 | void assignFacesVerticies(float (&face0Points)[4][3], |
el17cd | 22:236319885874 | 35 | float (&face1Points)[4][3], float (&face2Points)[4][3], |
el17cd | 22:236319885874 | 36 | float (&face3Points)[4][3], float (&face4Points)[4][3], |
el17cd | 22:236319885874 | 37 | float (&face5Points)[4][3]); |
el17cd | 23:eb50ab95bb53 | 38 | /** @brief sets the verticies of an individual face of the cube |
el17cd | 23:eb50ab95bb53 | 39 | *@param The memory address of the two dimentional float array which stores all x, y, z coordinates for the first faces verticies |
el17cd | 23:eb50ab95bb53 | 40 | *@param The memory address of the two dimentional float array which stores all x, y, z coordinates for the second faces verticies |
el17cd | 23:eb50ab95bb53 | 41 | *@param The memory address of the two dimentional float array which stores all x, y, z coordinates for the third faces verticies |
el17cd | 23:eb50ab95bb53 | 42 | *@param The memory address of the two dimentional float array which stores all x, y, z coordinates for the fourth faces verticies |
el17cd | 23:eb50ab95bb53 | 43 | *@param The memory address of the two dimentional float array which stores all x, y, z coordinates for the fifth faces verticies |
el17cd | 23:eb50ab95bb53 | 44 | *@param The memory address of the two dimentional float array which stores all x, y, z coordinates for the sixth faces verticies |
el17cd | 23:eb50ab95bb53 | 45 | */ |
el17cd | 16:64cd7bc094f9 | 46 | bool tooClose(); |
el17cd | 23:eb50ab95bb53 | 47 | /** @brief Returns whether the cube is too close to the perspective of the user |
el17cd | 23:eb50ab95bb53 | 48 | *@returns a boolean indicating whether it is too close or not |
el17cd | 23:eb50ab95bb53 | 49 | */ |
el17cd | 17:3c9672c6e532 | 50 | void rotateX(float angle); |
el17cd | 23:eb50ab95bb53 | 51 | /** @brief Performs a rotation in the X axis about the cubes centre |
el17cd | 23:eb50ab95bb53 | 52 | *@param The angle in which to rotate the cube in terms of radians, provided as a float |
el17cd | 23:eb50ab95bb53 | 53 | */ |
el17cd | 17:3c9672c6e532 | 54 | void rotateY(float angle); |
el17cd | 23:eb50ab95bb53 | 55 | /** @brief Performs a rotation in the Y axis about the cubes centre |
el17cd | 23:eb50ab95bb53 | 56 | *@param The angle in which to rotate the cube in terms of radians, provided as a float |
el17cd | 23:eb50ab95bb53 | 57 | */ |
el17cd | 17:3c9672c6e532 | 58 | void rotateZ(float angle); |
el17cd | 23:eb50ab95bb53 | 59 | /** @brief Performs a rotation in the Z axis about the cubes centre |
el17cd | 23:eb50ab95bb53 | 60 | *@param The angle in which to rotate the cube in terms of radians, provided as a float |
el17cd | 23:eb50ab95bb53 | 61 | */ |
el17cd | 17:3c9672c6e532 | 62 | void translate(float x, float y, float z); |
el17cd | 23:eb50ab95bb53 | 63 | /** @brief Performs a translation in all axis |
el17cd | 23:eb50ab95bb53 | 64 | *@param The x offset |
el17cd | 23:eb50ab95bb53 | 65 | *@param The y offset |
el17cd | 23:eb50ab95bb53 | 66 | *@param The z offset |
el17cd | 23:eb50ab95bb53 | 67 | */ |
el17cd | 20:3ca430241df0 | 68 | void resetPos(); |
el17cd | 23:eb50ab95bb53 | 69 | /** @brief Resets the position of the cube to the origin |
el17cd | 23:eb50ab95bb53 | 70 | */ |
el17cd | 16:64cd7bc094f9 | 71 | bool despawn(); |
el17cd | 23:eb50ab95bb53 | 72 | /** @brief Returns whether the cube is behind the users perspective |
el17cd | 23:eb50ab95bb53 | 73 | *@returns a boolean value as to whether it should be despawned or not |
el17cd | 23:eb50ab95bb53 | 74 | */ |
el17cd | 4:759a5c34e239 | 75 | }; |