2021-01-02 15:08:12 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <lvgl/src/lv_core/lv_obj.h>
|
2021-10-13 16:08:35 -04:00
|
|
|
#include "displayapp/screens/Screen.h"
|
2021-01-02 15:08:12 -05:00
|
|
|
|
|
|
|
namespace Pinetime {
|
|
|
|
namespace Applications {
|
2021-12-05 15:22:06 -05:00
|
|
|
struct TwosTile {
|
2021-01-02 15:08:12 -05:00
|
|
|
bool merged = false;
|
|
|
|
unsigned int value = 0;
|
|
|
|
};
|
|
|
|
namespace Screens {
|
|
|
|
class Twos : public Screen {
|
2021-04-24 05:00:45 -04:00
|
|
|
public:
|
2021-04-18 13:28:14 -04:00
|
|
|
Twos(DisplayApp* app);
|
|
|
|
~Twos() override;
|
2021-01-02 15:08:12 -05:00
|
|
|
|
2021-04-18 13:28:14 -04:00
|
|
|
bool OnTouchEvent(TouchEvents event) override;
|
2021-01-28 12:13:28 -05:00
|
|
|
|
2021-04-24 05:00:45 -04:00
|
|
|
private:
|
2022-09-11 14:57:49 -04:00
|
|
|
static constexpr int nColors = 5;
|
|
|
|
lv_style_t cellStyles[nColors];
|
2021-04-18 13:28:14 -04:00
|
|
|
|
|
|
|
lv_obj_t* scoreText;
|
|
|
|
lv_obj_t* gridDisplay;
|
2022-07-06 04:29:23 -04:00
|
|
|
static constexpr int nCols = 4;
|
|
|
|
static constexpr int nRows = 4;
|
|
|
|
static constexpr int nCells = nCols * nRows;
|
|
|
|
TwosTile grid[nRows][nCols];
|
2021-04-18 13:28:14 -04:00
|
|
|
unsigned int score = 0;
|
2022-07-06 04:29:23 -04:00
|
|
|
void updateGridDisplay();
|
|
|
|
bool tryMerge(int newRow, int newCol, int oldRow, int oldCol);
|
|
|
|
bool tryMove(int newRow, int newCol, int oldRow, int oldCol);
|
2021-04-18 13:28:14 -04:00
|
|
|
bool placeNewTile();
|
2021-01-02 15:08:12 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2021-07-19 09:26:12 -04:00
|
|
|
}
|