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: Paddle/Paddle.cpp
- Revision:
- 12:b3ec47d606a5
- Parent:
- 8:9b77eea95088
- Child:
- 13:3585d2ea4ff4
diff -r bb36db678a6d -r b3ec47d606a5 Paddle/Paddle.cpp
--- a/Paddle/Paddle.cpp Thu May 09 11:24:12 2019 +0000
+++ b/Paddle/Paddle.cpp Thu May 09 11:41:58 2019 +0000
@@ -3,7 +3,7 @@
/** Constructor */
Paddle::Paddle()
{
- reset(); /** initial parameters of paddle */
+ reset(); // initial parameters of paddle
}
/** Destructor - nothing happening here */
@@ -14,7 +14,7 @@
/** Adds the joystick control for the paddle */
void Paddle::controlPaddle(Gamepad &pad)
{
- /** Sets the joystick as the paddle controller */
+ // Sets the joystick as the paddle controller
_d = pad.get_direction();
}
@@ -22,20 +22,20 @@
/** Determines the movement physics of the paddle */
void Paddle::move()
{
- /** Moving right */
+ // Moving right
if (_d == E) {
- pos.x = pos.x + _speed; /** Adds speed to current position on x-axis */
+ pos.x = pos.x + _speed; // Adds speed to current position on x-axis
if (pos.x >= WIDTH - w) {
- pos.x = WIDTH - w; /** Sets the right-most limit to paddle*/
+ pos.x = WIDTH - w; // Sets the right-most limit to paddle
}
}
- /** Moving left */
+ // Moving left
if (_d == W) {
- pos.x = pos.x - _speed; /** Subtracts speed from current position on x-axis */
+ pos.x = pos.x - _speed; // Subtracts speed from current position on x-axis
if (pos.x <= 0) {
- pos.x = 0; /** Sets the left-most limit to paddle*/
+ pos.x = 0; // Sets the left-most limit to paddle
}
}
}
@@ -43,11 +43,11 @@
/** Resets paddle's initial parameters when game is over / lost */
void Paddle::reset()
{
- pos.x = WIDTH/2; /** position of paddle on x-axis */
- pos.y = HEIGHT - GAP; /** position of paddle on y-axis */
- velocity.x = 0; /** x-velocity of paddle is zero as it does not move by itself */
- velocity.y = 0; /** y-velocity of paddle is zero as it does not move by itself */
- w = 12; /** width of the paddle */
- h = 2; /** height of the paddle */
- _speed = 2; /** speed of movement of paddle */
+ pos.x = WIDTH/2; // position of paddle on x-axis
+ pos.y = HEIGHT - GAP; // position of paddle on y-axis
+ velocity.x = 0; // x-velocity of paddle is zero as it does not move by itself
+ velocity.y = 0; // y-velocity of paddle is zero as it does not move by itself
+ w = 12; // width of the paddle
+ h = 2; // height of the paddle
+ _speed = 2; // speed of movement of paddle
}
\ No newline at end of file