summaryrefslogtreecommitdiff
path: root/src/displayapp/screens/Paddle.cpp
diff options
context:
space:
mode:
authorKieran Cawthray <kieranc@gmail.com>2021-12-05 19:32:29 (GMT)
committerKieran Cawthray <kieranc@gmail.com>2021-12-05 19:32:29 (GMT)
commitc00ad4af352b8573f1bba6b691bc4d74a0d1aa77 (patch)
tree4dcf1509cf0cda12660d386005c203203f522e69 /src/displayapp/screens/Paddle.cpp
parent1b2a8a5a044d01978854b54fd30ed3737a041e9b (diff)
parent85a25302bfac215f9ec7b993f6a2c21a20ee223b (diff)
Merge remote-tracking branch 'upstream/develop' into pts-settings
Diffstat (limited to 'src/displayapp/screens/Paddle.cpp')
-rw-r--r--src/displayapp/screens/Paddle.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/displayapp/screens/Paddle.cpp b/src/displayapp/screens/Paddle.cpp
index 26c2368..608eb64 100644
--- a/src/displayapp/screens/Paddle.cpp
+++ b/src/displayapp/screens/Paddle.cpp
@@ -1,6 +1,8 @@
-#include "Paddle.h"
-#include "../DisplayApp.h"
-#include "../LittleVgl.h"
+#include "displayapp/screens/Paddle.h"
+#include "displayapp/DisplayApp.h"
+#include "displayapp/LittleVgl.h"
+
+#include <cstdlib> // for rand()
using namespace Pinetime::Applications::Screens;
@@ -50,6 +52,13 @@ void Paddle::Refresh() {
// checks if it has touched the side (right side)
if (ballX >= LV_HOR_RES - ballSize - 1) {
dx *= -1;
+ dy += rand() % 3 - 1; // add a little randomization in wall bounce direction, one of [-1, 0, 1]
+ if (dy > 5) { // limit dy to be in range [-5 to 5]
+ dy = 5;
+ }
+ if (dy < -5) {
+ dy = -5;
+ }
}
// checks if it is in the position of the paddle