2020-12-03 09:16:36 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <lvgl/lvgl.h>
|
|
|
|
#include <cstdint>
|
|
|
|
#include "Screen.h"
|
|
|
|
|
|
|
|
namespace Pinetime {
|
2020-12-03 10:27:54 -05:00
|
|
|
namespace Components {
|
|
|
|
class LittleVgl;
|
|
|
|
}
|
2020-12-03 09:16:36 -05:00
|
|
|
namespace Applications {
|
|
|
|
namespace Screens {
|
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
class Paddle : public Screen {
|
2021-04-24 05:00:45 -04:00
|
|
|
public:
|
2021-04-18 13:28:14 -04:00
|
|
|
Paddle(DisplayApp* app, Pinetime::Components::LittleVgl& lvgl);
|
|
|
|
~Paddle() override;
|
|
|
|
|
|
|
|
bool Refresh() override;
|
|
|
|
|
|
|
|
bool OnTouchEvent(TouchEvents event) override;
|
|
|
|
bool OnTouchEvent(uint16_t x, uint16_t y) override;
|
|
|
|
|
2021-04-24 05:00:45 -04:00
|
|
|
private:
|
2021-04-18 13:28:14 -04:00
|
|
|
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;
|
|
|
|
|
|
|
|
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
|
2020-12-03 09:16:36 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|