Dependencies:
mbed
« Back to documentation index
Cube Class Reference
Cube class.
More...
#include <Cube.h >
Public Member Functions
Cube ()
The constructor of the Cube class which instantiates the cube object.
Face getFace (int index)
An accessor method which gets a face of the cube depending on the index provided.
void setPartiallyVisible ()
Sets the front, left and right faces of the cube to be visible so that they will be rendered (only these 3 are ever seen during gameplay)
void setVisible ()
Sets the faces of the cube to be visible so that they will be rendered.
bool tooClose ()
Returns whether the cube is too close to the perspective of the user.
void rotateX (float angle)
Performs a rotation in the X axis about the cubes centre.
void rotateY (float angle)
Performs a rotation in the Y axis about the cubes centre.
void rotateZ (float angle)
Performs a rotation in the Z axis about the cubes centre.
void translate (float x, float y, float z)
Performs a translation in all axis.
void resetPos ()
Resets the position of the cube to the origin.
bool despawn ()
Returns whether the cube is behind the users perspective.
Detailed Description
Cube class.
A class used to instantiate a Cube object, this is the obstacle in the game and can be manipulated using the rotate and translate functions. The cubes will be constantly moving towards the user at an increasing speed proportional to the score, using the joystick will translate the cubes horizontally so that the user can dodge them.
Author: Christopher Doel
Date: April, 2019
Definition at line 14 of file Cube.h .
Constructor & Destructor Documentation
The constructor of the Cube class which instantiates the cube object.
No parameters are required as the cube is initially created with a size of 5 and a position at the origin.
Definition at line 9 of file Cube.cpp .
Member Function Documentation
Returns whether the cube is behind the users perspective.
Returns: a boolean value as to whether it should be despawned or not
Definition at line 175 of file Cube.cpp .
Face getFace
(
int
index )
An accessor method which gets a face of the cube depending on the index provided.
Parameters:
The integer index of the face required
Returns: A face object corresponding to the index provided
Definition at line 81 of file Cube.cpp .
Resets the position of the cube to the origin.
Definition at line 158 of file Cube.cpp .
void rotateX
(
float
angle )
Performs a rotation in the X axis about the cubes centre.
Parameters:
The angle in which to rotate the cube in terms of radians, provided as a float
Definition at line 126 of file Cube.cpp .
void rotateY
(
float
angle )
Performs a rotation in the Y axis about the cubes centre.
Parameters:
The angle in which to rotate the cube in terms of radians, provided as a float
Definition at line 92 of file Cube.cpp .
void rotateZ
(
float
angle )
Performs a rotation in the Z axis about the cubes centre.
Parameters:
The angle in which to rotate the cube in terms of radians, provided as a float
Definition at line 110 of file Cube.cpp .
void setPartiallyVisible
(
)
Sets the front, left and right faces of the cube to be visible so that they will be rendered (only these 3 are ever seen during gameplay)
Definition at line 30 of file Cube.cpp .
Sets the faces of the cube to be visible so that they will be rendered.
Definition at line 36 of file Cube.cpp .
Returns whether the cube is too close to the perspective of the user.
Returns: a boolean indicating whether it is too close or not
Definition at line 85 of file Cube.cpp .
void translate
(
float
x ,
float
y ,
float
z
)
Performs a translation in all axis.
Parameters:
The x offset
The y offset
The z offset
Definition at line 145 of file Cube.cpp .