Christopher Doel
/
el17cd
Cube Dodger A 3D 'endless runner' game
Game/Game.h@25:3995271e411c, 2019-04-03 (annotated)
- Committer:
- el17cd
- Date:
- Wed Apr 03 20:03:47 2019 +0000
- Revision:
- 25:3995271e411c
- Parent:
- 22:236319885874
- Child:
- 26:8a85aede976d
amended cube.cpp and documented cube.h
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
el17cd | 15:8fbbdefbe720 | 1 | #include <vector> |
el17cd | 15:8fbbdefbe720 | 2 | #ifndef FACE_H |
el17cd | 15:8fbbdefbe720 | 3 | #define FACE_H |
el17cd | 15:8fbbdefbe720 | 4 | #include "Face.h" |
el17cd | 15:8fbbdefbe720 | 5 | #endif |
el17cd | 15:8fbbdefbe720 | 6 | #include "Rasturizer.h" |
el17cd | 16:64cd7bc094f9 | 7 | #ifndef CUBE_H |
el17cd | 16:64cd7bc094f9 | 8 | #define CUBE_H |
el17cd | 15:8fbbdefbe720 | 9 | #include "Cube.h" |
el17cd | 16:64cd7bc094f9 | 10 | #endif |
el17cd | 15:8fbbdefbe720 | 11 | #include "Gamepad.h" |
el17cd | 15:8fbbdefbe720 | 12 | #include "mbed.h" |
el17cd | 15:8fbbdefbe720 | 13 | |
el17cd | 25:3995271e411c | 14 | /** Game class |
el17cd | 25:3995271e411c | 15 | *@brief A class used to instantiate a cube object, this is the obstacle in the game |
el17cd | 25:3995271e411c | 16 | *@author Christopher Doel |
el17cd | 25:3995271e411c | 17 | *@date April, 2019 |
el17cd | 25:3995271e411c | 18 | */ |
el17cd | 25:3995271e411c | 19 | |
el17cd | 15:8fbbdefbe720 | 20 | class Game { |
el17cd | 15:8fbbdefbe720 | 21 | private: |
el17cd | 25:3995271e411c | 22 | bool backToMenu; |
el17cd | 20:3ca430241df0 | 23 | int noOfCubes; |
el17cd | 18:8256546a3cbf | 24 | int homeSelection; |
el17cd | 25:3995271e411c | 25 | bool deathMenuSelection; |
el17cd | 15:8fbbdefbe720 | 26 | bool playing; |
el17cd | 15:8fbbdefbe720 | 27 | int score; |
el17cd | 22:236319885874 | 28 | Vector2D coord; |
el17cd | 25:3995271e411c | 29 | Cube cubeArray[25]; |
el17cd | 25:3995271e411c | 30 | Face faceArray[150]; |
el17cd | 21:6b5d2d75e083 | 31 | |
el17cd | 15:8fbbdefbe720 | 32 | Ticker ticker; |
el17cd | 15:8fbbdefbe720 | 33 | Gamepad gamepad; |
el17cd | 15:8fbbdefbe720 | 34 | Rasturizer renderer; |
el17cd | 21:6b5d2d75e083 | 35 | |
el17cd | 21:6b5d2d75e083 | 36 | void addScore(); |
el17cd | 25:3995271e411c | 37 | /** @brief Increments the score by 1 |
el17cd | 25:3995271e411c | 38 | */ |
el17cd | 21:6b5d2d75e083 | 39 | void resetScore(); |
el17cd | 25:3995271e411c | 40 | /** @brief Resets the score to 0 |
el17cd | 25:3995271e411c | 41 | */ |
el17cd | 25:3995271e411c | 42 | void checkDespawn(Cube *cube); |
el17cd | 25:3995271e411c | 43 | /** @brief Checks whether a cube needs to be despawned, if it does then the cube will be translated to the far side of the map |
el17cd | 25:3995271e411c | 44 | *@param A pointer to a cube object |
el17cd | 25:3995271e411c | 45 | */ |
el17cd | 25:3995271e411c | 46 | void checkDeath(Cube *cube); |
el17cd | 25:3995271e411c | 47 | /** @brief Checks whether a cube is too close to the user and therefore a collision has occured, the game will be stopped if true |
el17cd | 25:3995271e411c | 48 | *@param A pointer to a cube object |
el17cd | 25:3995271e411c | 49 | */ |
el17cd | 25:3995271e411c | 50 | void cubeToBeRendered(Cube *cube, int cubeIndex); |
el17cd | 25:3995271e411c | 51 | /** @brief Adds the cubes faces to the array of faces to be passed to the renderer |
el17cd | 25:3995271e411c | 52 | *@param A pointer to a cube object |
el17cd | 25:3995271e411c | 53 | *@param The integer index of the cubes position in the cube array |
el17cd | 25:3995271e411c | 54 | */ |
el17cd | 25:3995271e411c | 55 | void moveCubes(Cube *cube); |
el17cd | 25:3995271e411c | 56 | /** @brief Translates the cube in the z axis towards the user (speed dependant on score) and left and right depending on the joystick location |
el17cd | 25:3995271e411c | 57 | *@param A pointer to a cube object |
el17cd | 25:3995271e411c | 58 | */ |
el17cd | 25:3995271e411c | 59 | void displayDeathMenu(); |
el17cd | 25:3995271e411c | 60 | /** @brief Displays the menu screen if the game has stopeed propting the user to either restart or go to the home menu |
el17cd | 25:3995271e411c | 61 | */ |
el17cd | 25:3995271e411c | 62 | void deathButtonSelections(); |
el17cd | 25:3995271e411c | 63 | /** @brief Determines the action to be taken depending on the button input once the game has ended |
el17cd | 25:3995271e411c | 64 | */ |
el17cd | 18:8256546a3cbf | 65 | void homeButtonSelections(); |
el17cd | 25:3995271e411c | 66 | /** @brief Determines the action to be taken depending on the button input at the home screen |
el17cd | 25:3995271e411c | 67 | */ |
el17cd | 15:8fbbdefbe720 | 68 | public: |
el17cd | 15:8fbbdefbe720 | 69 | Game(); |
el17cd | 15:8fbbdefbe720 | 70 | void run(); |
el17cd | 25:3995271e411c | 71 | /** @brief Executes the game loop |
el17cd | 25:3995271e411c | 72 | */ |
el17cd | 18:8256546a3cbf | 73 | void homeScreen(); |
el17cd | 25:3995271e411c | 74 | /** @brief Executed the home screen loop |
el17cd | 25:3995271e411c | 75 | */ |
el17cd | 15:8fbbdefbe720 | 76 | }; |