summaryrefslogtreecommitdiff
path: root/src/displayapp/screens/Twos.h
blob: ec0219718dd1cdedf039f5314a6992a03f935bb0 (plain)
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
40
41
#pragma once

#include <lvgl/src/lv_core/lv_obj.h>
#include "Screen.h"

namespace Pinetime {
  namespace Applications {
    struct Tile {
      bool merged = false;
      unsigned int value = 0;
    };
    namespace Screens {
      class Twos : public Screen {
        public:
          Twos(DisplayApp* app);
          ~Twos() override;
          bool Refresh() override;
          bool OnButtonPushed() override;
          bool OnTouchEvent(TouchEvents event) override;

        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;
          
          bool running = true;
          lv_obj_t *scoreText;
          lv_obj_t *gridDisplay;
          Tile grid[4][4];
          unsigned int score = 0;
          void updateGridDisplay(Tile grid[][4]);
          bool tryMerge(Tile grid[][4], int &newRow, int &newCol, int oldRow, int oldCol);
          bool tryMove(Tile grid[][4], int newRow, int newCol, int oldRow, int oldCol);
          bool placeNewTile();
      };
    }
  }
}