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: Ball/Ball.cpp
- Revision:
- 13:3585d2ea4ff4
- Parent:
- 12:b3ec47d606a5
--- a/Ball/Ball.cpp Thu May 09 11:41:58 2019 +0000 +++ b/Ball/Ball.cpp Thu May 09 11:55:47 2019 +0000 @@ -2,18 +2,15 @@ #include "Paddle.h" #include <math.h> -/** Constructor */ Ball::Ball() { reset(); // initial parameters of ball } -/** Destructor - nothing happens here */ Ball::~Ball() { } -/** Ball screen edge detection and movement */ void Ball::move() { GameObject::move(); @@ -51,8 +48,8 @@ // printf("angle of right: %.02f\n", atan2(0.f, 1)); // printf("angle of up: %.02f\n", atan2(-1.f, 0)); -// Standard rotation of a vector by given degrees */ -// Example of this function to play around with: https://repl.it/repls/HopefulTrimWordprocessing */ +// Standard rotation of a vector by given degrees +// Example of this function to play around with: https://repl.it/repls/HopefulTrimWordprocessing void Rotate(Vector2D& v, float degrees) { float s = (float)sin(degrees * Deg2Rad); // stores sin value betweem -1 and 1 @@ -74,9 +71,7 @@ return min(max(x, minn), maxx); } - -/** Collision detection between ball and paddle */ void Ball::hitPad(Paddle &paddle) { const Vector2D& posPad = paddle.getPos(); @@ -110,7 +105,6 @@ } -/** Randomizes the initial x-direction of the ball */ int Ball::randomize() { AnalogIn noisy(PTB0); // Disconnected pin so will have random noise @@ -125,7 +119,6 @@ return movement; } -/** Resets ball's initial parameters when game is over / lost */ void Ball::reset() { pos.x = WIDTH/2; // initial position of ball on x-axis