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:
- 5:12c179da4788
- Parent:
- 4:0e01cbb95434
- Child:
- 6:39bda45efeed
--- a/Ball/Ball.cpp Sat Mar 23 12:07:33 2019 +0000 +++ b/Ball/Ball.cpp Tue Mar 26 09:16:35 2019 +0000 @@ -5,13 +5,12 @@ int g_xBall = WIDTH/2; // draw ball in the middle of the columns initially int g_yBall = HEIGHT - GAP - 2; // draw ball close to the bottom of the LCD -int g_counterx = 1; -int g_countery = 1; // Constructor Ball::Ball() { - + _counterx = 1; + _countery = 1; } // Destructor @@ -28,24 +27,24 @@ void Ball::moveBall() { - g_xBall += g_counterx; - g_yBall -= g_countery; + g_xBall += _counterx; + g_yBall -= _countery; if (g_xBall > 83) { - g_counterx = -1; + _counterx = -1; } else if(g_xBall < 1) { - g_counterx = 1; + _counterx = 1; } if (g_yBall < 1) { - g_countery = -1; + _countery = -1; } else if (g_yBall > 47) { - g_countery = 1; + _countery = 1; } } @@ -55,8 +54,8 @@ Vector2D posPad = pl.get_padPos(pad); if (posBall.y == posPad.y - 1 && (posBall.x >= posPad.x && posBall.x <= posPad.x + 12)) { - g_countery = !g_countery; - printf("\nball x = %f, ball y = %f \n pad x = %f, pad y = %f ",posBall.x, posBall.y, posPad.x, posPad.y); + _countery = !_countery; + //printf("\nball x = %f, ball y = %f \n pad x = %f, pad y = %f ",posBall.x, posBall.y, posPad.x, posPad.y); } @@ -95,9 +94,9 @@ { g_xBall = WIDTH/2; g_yBall = HEIGHT - GAP - 2; - g_counterx = 1; - g_countery = 1; - g_xBall += g_counterx; - g_yBall -= g_countery; + _counterx = 1; + _countery = 1; + g_xBall += _counterx; + g_yBall -= _countery; pl.padReset(); } \ No newline at end of file