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.
Diff: Game/Game.cpp
- Revision:
- 11:db27d3838514
- Parent:
- 10:58cf89dd878c
- Child:
- 12:5549a299d41e
diff -r 58cf89dd878c -r db27d3838514 Game/Game.cpp --- a/Game/Game.cpp Mon May 06 10:11:42 2019 +0000 +++ b/Game/Game.cpp Mon May 06 14:43:01 2019 +0000 @@ -7,20 +7,31 @@ @version 1.0 +@author Joshua Davy el17jd -// constructor +@date April 2019 + +*/ + +/** +* @brief Constructor (no paramateters) +*/ Game::Game() { } -//deconstructor +/** +* @brief Deconstructor +*/ Game::~Game() { } - - +/** +* @brief Loads the specified level. +* @param level_number @details The level number to load. +*/ void Game::load_level(int level_number) { // I would of done this large switch statement with a an array @@ -65,16 +76,13 @@ // Initalises level _level.init(level_def.blocks, level_def.number_of_blocks, - level_def.goal); - - - for (int i = 0; i < level_def.number_of_moving_blocks; i++) { - MovingBlockDefinition x = level_def.moving_blocks[i]; - _level.declare_moving_block(x.index,x.extending,x.distance); - } - + level_def.goal, + level_def.moving_blocks, + level_def.number_of_moving_blocks); } - +/** +* @brief Initalises the game and loads the first level. +*/ void Game::init() { // Loads the first level @@ -84,8 +92,11 @@ _game_won = false; } - - +/** +* @brief Updates the game this should be called every frame. Updates player +* and block positions and loads the next level if the goal is reached. +* @param pad @details the Gamepad object. +*/ void Game::update(Gamepad &pad) { // Update player position based on gamepad presses/ collisions @@ -101,7 +112,10 @@ } } - +/** +* @brief Draws the current state on the screen. Should be called every frame. +* @param lcd @details the N5110 lcd object +*/ void Game::draw(N5110 &lcd) { // Clear screen buffer @@ -115,8 +129,10 @@ lcd.refresh(); } - - +/** +* @brief Returns if the game has been won +* @returns if the game has been won. +*/ bool Game::game_won() { return _game_won;