ref: 9196c18d376d4f18c686bcfec8550f9c8659d5ea
src/displayapp/screens/Twos.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
#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 { public: Twos(); ~Twos() override; bool OnTouchEvent(TouchEvents event) override; private: static constexpr int nColors = 5; lv_style_t cellStyles[nColors]; lv_obj_t* scoreText; lv_obj_t* gridDisplay; static constexpr int nCols = 4; static constexpr int nRows = 4; static constexpr int nCells = nCols * nRows; TwosTile grid[nRows][nCols]; unsigned int score = 0; void updateGridDisplay(); bool tryMerge(int newRow, int newCol, int oldRow, int oldCol); bool tryMove(int newRow, int newCol, int oldRow, int oldCol); bool placeNewTile(); }; } } } |