42 lines
1.0 KiB
C
Raw Normal View History

#pragma once
#include <lvgl/src/lv_core/lv_obj.h>
#include "displayapp/screens/Screen.h"
namespace Pinetime {
namespace Applications {
struct TwosTile {
bool merged = false;
unsigned int value = 0;
};
namespace Screens {
class Twos : public Screen {
2021-04-24 12:00:45 +03:00
public:
Twos(DisplayApp* app);
~Twos() override;
bool OnTouchEvent(TouchEvents event) override;
2021-01-28 17:13:28 +00:00
2021-04-24 12:00:45 +03:00
private:
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;
2022-07-06 11:29:23 +03:00
static constexpr int nCols = 4;
static constexpr int nRows = 4;
static constexpr int nCells = nCols * nRows;
TwosTile grid[nRows][nCols];
unsigned int score = 0;
2022-07-06 11:29:23 +03:00
void updateGridDisplay();
bool tryMerge(int newRow, int newCol, int oldRow, int oldCol);
bool tryMove(int newRow, int newCol, int oldRow, int oldCol);
bool placeNewTile();
};
}
}
2021-07-19 16:26:12 +03:00
}