diff options
| author | Michele Bini <michele.bini@gmail.com> | 2022-06-06 18:27:54 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2022-06-06 23:09:58 (GMT) |
| commit | 7c45f185a32c7bcff47c8fda1acdec82d3213717 (patch) | |
| tree | 53b0419fe2a19e6ec5c89d0be0a11dcd8d4ceb00 /src/displayapp/screens/Paddle.cpp | |
| parent | 94b1b330fc1f6e941a797fedabade4e790e28bc2 (diff) | |
| parent | 35dcf8c8607483c104711c9398d47d57147f4389 (diff) | |
Merge remote-tracking branch 'origin/develop' into analog24
Diffstat (limited to 'src/displayapp/screens/Paddle.cpp')
| -rw-r--r-- | src/displayapp/screens/Paddle.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/displayapp/screens/Paddle.cpp b/src/displayapp/screens/Paddle.cpp index 79401ff..1fb2508 100644 --- a/src/displayapp/screens/Paddle.cpp +++ b/src/displayapp/screens/Paddle.cpp @@ -53,7 +53,7 @@ void Paddle::Refresh() { 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] + if (dy > 5) { // limit dy to be in range [-5 to 5] dy = 5; } if (dy < -5) { @@ -85,7 +85,14 @@ bool Paddle::OnTouchEvent(Pinetime::Applications::TouchEvents event) { bool Paddle::OnTouchEvent(uint16_t x, uint16_t y) { // sets the center paddle pos. (30px offset) with the the y_coordinate of the finger - lv_obj_set_pos(paddle, 0, y - 30); + // but clamp it such that the paddle never clips off screen + if (y < 31) { + lv_obj_set_pos(paddle, 0, 1); + } else if (y > LV_VER_RES - 31) { + lv_obj_set_pos(paddle, 0, LV_VER_RES - 61); + } else { + lv_obj_set_pos(paddle, 0, y - 30); + } paddlePos = y; return true; } |
