2020-12-03 15:16:36 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <lvgl/lvgl.h>
|
|
|
|
#include <cstdint>
|
|
|
|
#include "Screen.h"
|
|
|
|
|
|
|
|
namespace Pinetime {
|
2020-12-03 16:27:54 +01:00
|
|
|
namespace Components {
|
|
|
|
class LittleVgl;
|
|
|
|
}
|
2020-12-03 15:16:36 +01:00
|
|
|
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:
|
2020-12-03 16:27:54 +01:00
|
|
|
Pinetime::Components::LittleVgl& lvgl;
|
|
|
|
|
2020-12-08 05:20:44 +01:00
|
|
|
int PaddleBottomY = 90; // bottom extreme of the paddle
|
|
|
|
int PaddleTopY = 150; //top extreme of the paddle
|
2020-12-03 15:16:36 +01:00
|
|
|
|
2020-12-08 05:20:44 +01:00
|
|
|
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
|
2020-12-03 15:16:36 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2020-12-08 05:20:44 +01:00
|
|
|
char scoreStr[10];
|
|
|
|
|
|
|
|
lv_img_dsc_t paddle;
|
|
|
|
lv_img_dsc_t ball;
|
2020-12-03 15:16:36 +01:00
|
|
|
|
|
|
|
lv_obj_t* points;
|
2020-12-08 05:20:44 +01:00
|
|
|
lv_obj_t* paddle_image; // pointer to paddle image
|
|
|
|
lv_obj_t* ball_image; // pointer to ball image
|
2020-12-03 15:16:36 +01:00
|
|
|
|
|
|
|
bool running = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|