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
Diff: Doodler/Doodler.h
- Revision:
- 26:d16a5b1e0ace
- Parent:
- 25:f122e1862cd1
- Child:
- 29:15e9640646b7
diff -r f122e1862cd1 -r d16a5b1e0ace Doodler/Doodler.h
--- a/Doodler/Doodler.h Wed May 08 15:07:04 2019 +0000
+++ b/Doodler/Doodler.h Wed May 08 17:24:35 2019 +0000
@@ -15,11 +15,14 @@
Doodler();
~Doodler();
/**
- @brief Defines the initial position of the bullet
+ @brief Defines the initial position of the doodler
@param float position_x uses float since the velocity will be added, which is not an integer.
@param float position_y uses float since the velocity will be added, which is not an integer.
- @param double velocity_y needs to be double in order for it to decelerate to a small value that approaches zero.
- @details The intial position of the doodler is at the centre of the screen and the values are gotten from the Engine class. It also defines the gravity as a positive vale greater than 1 and the up object as a negative vale less than 1.
+ @param double velocity_y needs to be double in order for it to decelerate to a small value that
+ approaches zero.
+ @details The intial position of the doodler is at the centre of the screen and the values are
+ gotten from the Engine class. It also defines the gravity as a positive vale greater than 1
+ and the up object as a negative vale less than 1.
*/
void init(float position_x, float position_y, double velocity_y);
@@ -32,22 +35,27 @@
/**
@brief Updates the position of the doodler
- @param Direction d is gotten from the user input of the joystick and determines the movement of the doodler in the x-direction. It moves left/right if the joystick directs left/right at an angle or not.
- @param float mag is used to accelerate the movement of the doodler in the x-direction since it moves 5 frames * the magnitude of the joystick.
+ @param Direction d is gotten from the user input of the joystick and determines the movement of
+ the doodler in the x-direction. It moves left/right if the joystick directs left/right at an angle
+ or not.
+ @param float mag is used to accelerate the movement of the doodler in the x-direction since it
+ moves 5 frames * the magnitude of the joystick.
@details The function checks the doodler does not leave the screen rectangle (30 x 83) in the
- x-direction and checks the direction of the velocity to keep adding or substructing a value in the y-direction (depending on if it is jumping or falling)
+ x-direction and checks the direction of the velocity to keep adding or substructing a value in
+ the y-direction (depending on if it is jumping or falling)
*/
void update(Direction d, float mag);
/**
@brief Function to check the doodler's y-coodinate velocity
- @details The function checks the current velocity of the doodler and depending on
- its direction (positive or negative) it will decide if the doodler's updated velocity will remain the same or change direction (jump).
- If the velocity is positive, it means it is currently jumping, so it should continue doing so but in a decreasing velocity (decelerating),
- which is why it is multiplied times the _up constant (value less than 1).
- If the velocity is negative it means it is falling downwards and increasing in velocity (accelerating). This is done by multiplying the
- current velocity by the gravity constant value (greater than 1).
- Finally, if the velocity is 0, it means it has completely decelerated upwards and so it should begin to fall. To do so, the velocity
+ @details The function checks the current velocity of the doodler and depending on its direction
+ (positive or negative) it will decide if the doodler's updated velocity will remain the same or
+ change direction (jump). If the velocity is positive, it means it is currently jumping, so it
+ should continue doing so but in a decreasing velocity (decelerating), which is why it is
+ multiplied times the _up constant (value less than 1). If the velocity is negative it means
+ it is falling downwards and increasing in velocity (accelerating). This is done by multiplying the
+ current velocity by the gravity constant value (greater than 1). Finally, if the velocity is 0, it
+ means it has completely decelerated upwards and so it should begin to fall. To do so, the velocity
is given the value of gravity (which is a positive value).
*/
void check_velocity();
@@ -60,7 +68,8 @@
/**
@brief Returns the current doodler's velocity in the y-axis
- @details Gets the current value in the doodler's class for the doodler's velocity in the y-axis. It is a double value since the y-velocity is a double type.
+ @details Gets the current value in the doodler's class for the doodler's velocity in the y-axis. It is a
+ double value since the y-velocity is a double type.
*/
double get_velocity_y();
@@ -77,18 +86,20 @@
float get_position_y();
/**
- @brief Sets the doodler's velocity in the doodler's class to the parameters inputed
+ @brief Sets the doodler's velocity in the Doodler's class to equal the inputed parameters
@param float vel_x
@param float vel_y
- @details The function sets the doodler's velocity in the doodler's class by making the current velocity equal to the parameters inputed to the function
+ @details The function sets the doodler's velocity in the doodler's class by making the current
+ velocity equal to the inputed parameters
*/
void set_velocity(float vel_x, double vel_y);
/**
- @brief Sets the doodler's position in the doodler's class to the parameters inputed
+ @brief Sets the doodler's position in the Doodler's class to equal the inputed parameters
@param float pos_x
@param float pos_y
- @details The function sets the doodler's position in the doodler's class by making the current position equal the parameters inputed to the function
+ @details The function sets the doodler's position in the doodler's class by making the current
+ position equal the inputed parameters
*/
void set_position(float pos_x, float pos_y);