2021-01-02 20:08:12 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <lvgl/src/lv_core/lv_obj.h>
|
2021-10-13 20:08:35 +00:00
|
|
|
#include "displayapp/screens/Screen.h"
|
2021-01-02 20:08:12 +00:00
|
|
|
|
|
|
|
namespace Pinetime {
|
|
|
|
namespace Applications {
|
2021-12-05 20:22:06 +00:00
|
|
|
struct TwosTile {
|
2021-01-02 20:08:12 +00:00
|
|
|
bool merged = false;
|
|
|
|
unsigned int value = 0;
|
|
|
|
};
|
|
|
|
namespace Screens {
|
|
|
|
class Twos : public Screen {
|
2021-04-24 09:00:45 +00:00
|
|
|
public:
|
2021-04-18 17:28:14 +00:00
|
|
|
Twos(DisplayApp* app);
|
|
|
|
~Twos() override;
|
2021-01-02 20:08:12 +00:00
|
|
|
|
2021-04-18 17:28:14 +00:00
|
|
|
bool OnTouchEvent(TouchEvents event) override;
|
2021-01-28 17:13:28 +00:00
|
|
|
|
2021-04-24 09:00:45 +00:00
|
|
|
private:
|
2021-04-18 17:28:14 +00:00
|
|
|
lv_style_t style_cell1;
|
|
|
|
lv_style_t style_cell2;
|
|
|
|
lv_style_t style_cell3;
|
|
|
|
lv_style_t style_cell4;
|
|
|
|
lv_style_t style_cell5;
|
|
|
|
|
|
|
|
lv_obj_t* scoreText;
|
|
|
|
lv_obj_t* gridDisplay;
|
2021-12-05 20:22:06 +00:00
|
|
|
TwosTile grid[4][4];
|
2021-04-18 17:28:14 +00:00
|
|
|
unsigned int score = 0;
|
2021-12-05 20:22:06 +00:00
|
|
|
void updateGridDisplay(TwosTile grid[][4]);
|
|
|
|
bool tryMerge(TwosTile grid[][4], int& newRow, int& newCol, int oldRow, int oldCol);
|
|
|
|
bool tryMove(TwosTile grid[][4], int newRow, int newCol, int oldRow, int oldCol);
|
2021-04-18 17:28:14 +00:00
|
|
|
bool placeNewTile();
|
2021-01-02 20:08:12 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2021-07-19 13:26:12 +00:00
|
|
|
}
|