summaryrefslogtreecommitdiff
path: root/src/displayapp/screens
diff options
context:
space:
mode:
authorZephyrLabs <65145081+ZephyrLabs@users.noreply.github.com>2020-12-20 09:32:00 +0530
committerZephyrLabs <65145081+ZephyrLabs@users.noreply.github.com>2020-12-20 09:32:00 +0530
commit61e78d338b9dbf620e0292dcd15252da131a2bd3 (patch)
tree0f249e270e32de7416d72170bff725c024e5b512 /src/displayapp/screens
parent020840e04fb922db509a9f1289e1c856801566da (diff)
Update Paddle.cpp
fix uppercase
Diffstat (limited to 'src/displayapp/screens')
-rw-r--r--src/displayapp/screens/Paddle.cpp29
1 files changed, 13 insertions, 16 deletions
diff --git a/src/displayapp/screens/Paddle.cpp b/src/displayapp/screens/Paddle.cpp
index 14ae2202..347abb62 100644
--- a/src/displayapp/screens/Paddle.cpp
+++ b/src/displayapp/screens/Paddle.cpp
@@ -134,39 +134,37 @@ Paddle::~Paddle() {
}
bool Paddle::Refresh() {
-
if((counter++ % 5) == 0){
-
counter = 0;
- BallX += dx;
- BallY += dy;
+ ballX += dx;
+ ballY += dy;
- lv_obj_set_pos(ball_image, BallX, BallY);
+ lv_obj_set_pos(ball_image, ballX, ballY);
//checks if it has touched the sides (floor and ceiling)
- if(BallY <= 0 || BallY >= 215){
+ if(ballY <= 0 || ballY >= 215){
dy *= -1;
}
//checks if it has touched the side (left side)
- if(BallX >= 215){
+ if(ballX >= 215){
dx *= -1;
}
//checks if it is in the position of the paddle
- if(BallY <= (PaddleBottomY + 16) && BallY >= (PaddleTopY - 8)){
- if(BallX >= 0 && BallX < 4){
- lv_obj_set_pos(ball_image, 5, BallY);
+ if(ballY <= (paddleBottomY + 16) && ballY >= (paddleTopY - 8)){
+ if(ballX >= 0 && ballX < 4){
+ lv_obj_set_pos(ball_image, 5, ballY);
dx *= -1;
score++;
}
}
//checks if it has gone behind the paddle
- else if(BallX <= -40){
- BallX = 107;
- BallY = 107;
+ else if(ballX <= -40){
+ ballX = 107;
+ ballY = 107;
score = 0;
}
sprintf(scoreStr, "%d", score);
@@ -185,10 +183,9 @@ bool Paddle::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
}
bool Paddle::OnTouchEvent(uint16_t x, uint16_t y) {
-
lv_obj_set_pos(paddle_image, 0, y - 30); // sets the center paddle pos. (30px offset) with the the y_coordinate of the finger and defaults the x_coordinate to 0
- PaddleTopY = y - 30; // refreshes the upper extreme of the paddle
- PaddleBottomY = y + 30; // refreshes the lower extreme of the paddle
+ paddleTopY = y - 30; // refreshes the upper extreme of the paddle
+ paddleBottomY = y + 30; // refreshes the lower extreme of the paddle
return true;
}