summaryrefslogtreecommitdiff
path: root/src/displayapp/screens/Paddle.h
diff options
context:
space:
mode:
authorJF002 <JF002@users.noreply.github.com>2020-12-20 11:19:23 +0100
committerGitHub <noreply@github.com>2020-12-20 11:19:23 +0100
commit276c8aa308f923aeeadc068967b15ee7c59fa32b (patch)
treedf060165f6d8029dcdea3d74e581ce4f508579d7 /src/displayapp/screens/Paddle.h
parent7c8fb9a46855ddc50f6e0703e4bd771faa3fb61c (diff)
parentcc04c2c1f8a8a05cf284ad69a43b5cd682e37172 (diff)
Merge pull request #147 from ZephyrLabs/Paddle-app
Paddle-app (updated)
Diffstat (limited to 'src/displayapp/screens/Paddle.h')
-rw-r--r--src/displayapp/screens/Paddle.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/displayapp/screens/Paddle.h b/src/displayapp/screens/Paddle.h
new file mode 100644
index 00000000..358bd2f5
--- /dev/null
+++ b/src/displayapp/screens/Paddle.h
@@ -0,0 +1,52 @@
+#pragma once
+
+#include <lvgl/lvgl.h>
+#include <cstdint>
+#include "Screen.h"
+
+namespace Pinetime {
+ namespace Components {
+ class LittleVgl;
+ }
+ namespace Applications {
+ namespace Screens {
+
+ class Paddle : public Screen{
+ public:
+ Paddle(DisplayApp* app, Pinetime::Components::LittleVgl& lvgl);
+ ~Paddle() override;
+
+ bool Refresh() override;
+ bool OnButtonPushed() override;
+ bool OnTouchEvent(TouchEvents event) override;
+ bool OnTouchEvent(uint16_t x, uint16_t y) override;
+
+ private:
+ Pinetime::Components::LittleVgl& lvgl;
+
+ int paddleBottomY = 90; // bottom extreme of the paddle
+ int paddleTopY = 150; //top extreme of the paddle
+
+ int ballX = 107; // Initial x_coordinate for the ball (12px offset from the center to counteract the ball's 24px size)
+ int ballY = 107; // Initial y_coordinate for the ball
+
+ int dx = 2; // Velocity of the ball in the x_coordinate
+ int dy = 3; // Velocity of the ball in the y_coordinate
+
+ int counter = 0; // init Frame refresh limit counter
+ int score = 0;
+
+ char scoreStr[10];
+
+ lv_img_dsc_t paddle;
+ lv_img_dsc_t ball;
+
+ lv_obj_t* points;
+ lv_obj_t* paddle_image; // pointer to paddle image
+ lv_obj_t* ball_image; // pointer to ball image
+
+ bool running = true;
+ };
+ }
+ }
+}