2020-12-03 14:16:36 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <lvgl/lvgl.h>
|
|
|
|
#include <cstdint>
|
2021-10-13 20:08:35 +00:00
|
|
|
#include "displayapp/screens/Screen.h"
|
2020-12-03 14:16:36 +00:00
|
|
|
|
|
|
|
namespace Pinetime {
|
2020-12-03 15:27:54 +00:00
|
|
|
namespace Components {
|
|
|
|
class LittleVgl;
|
|
|
|
}
|
2020-12-03 14:16:36 +00:00
|
|
|
namespace Applications {
|
|
|
|
namespace Screens {
|
|
|
|
|
2021-04-18 17:28:14 +00:00
|
|
|
class Paddle : public Screen {
|
2021-04-24 09:00:45 +00:00
|
|
|
public:
|
2021-04-18 17:28:14 +00:00
|
|
|
Paddle(DisplayApp* app, Pinetime::Components::LittleVgl& lvgl);
|
|
|
|
~Paddle() override;
|
|
|
|
|
2021-07-19 13:26:12 +00:00
|
|
|
void Refresh() override;
|
2021-04-18 17:28:14 +00:00
|
|
|
|
|
|
|
bool OnTouchEvent(TouchEvents event) override;
|
|
|
|
bool OnTouchEvent(uint16_t x, uint16_t y) override;
|
|
|
|
|
2021-04-24 09:00:45 +00:00
|
|
|
private:
|
2021-04-18 17:28:14 +00:00
|
|
|
Pinetime::Components::LittleVgl& lvgl;
|
|
|
|
|
2021-06-24 10:33:15 +00:00
|
|
|
const uint8_t ballSize = 16;
|
2021-04-18 17:28:14 +00:00
|
|
|
|
2021-06-24 10:33:15 +00:00
|
|
|
uint16_t paddlePos = 30; // Paddle center
|
2021-04-18 17:28:14 +00:00
|
|
|
|
2021-06-24 10:33:15 +00:00
|
|
|
int16_t ballX = (LV_HOR_RES - ballSize) / 2;
|
|
|
|
int16_t ballY = (LV_VER_RES - ballSize) / 2;
|
2021-04-18 17:28:14 +00:00
|
|
|
|
2021-06-24 10:33:15 +00:00
|
|
|
int8_t dx = 2; // Velocity of the ball in the x_coordinate
|
|
|
|
int8_t dy = 3; // Velocity of the ball in the y_coordinate
|
2021-04-18 17:28:14 +00:00
|
|
|
|
2021-06-24 10:33:15 +00:00
|
|
|
uint16_t score = 0;
|
2021-04-18 17:28:14 +00:00
|
|
|
|
|
|
|
lv_obj_t* points;
|
2021-06-24 10:33:15 +00:00
|
|
|
lv_obj_t* paddle;
|
|
|
|
lv_obj_t* ball;
|
|
|
|
lv_obj_t* background;
|
2021-07-19 13:26:12 +00:00
|
|
|
|
|
|
|
lv_task_t* taskRefresh;
|
2020-12-03 14:16:36 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|