aboutsummaryrefslogtreecommitdiffstats
path: root/src/displayapp/screens/Twos.h
diff options
context:
space:
mode:
authorJF002 <JF002@users.noreply.github.com>2021-01-03 13:40:29 +0000
committerGitHub <noreply@github.com>2021-01-03 13:40:29 +0000
commit033a09db6d3dc515bd32b942809feb5059679cfc (patch)
tree0994e88f94125833d6fc8a3f474acb3daa6f4229 /src/displayapp/screens/Twos.h
parente0082f0ae33a809480ee409ccffdd136c13248e4 (diff)
parent12617ed1bf0738970c1ccf32d0b523e6d5999531 (diff)
Merge pull request #154 from jedmijares/twos-game
Adds 2048 clone game
Diffstat (limited to 'src/displayapp/screens/Twos.h')
-rw-r--r--src/displayapp/screens/Twos.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/displayapp/screens/Twos.h b/src/displayapp/screens/Twos.h
new file mode 100644
index 00000000..ad80ca15
--- /dev/null
+++ b/src/displayapp/screens/Twos.h
@@ -0,0 +1,34 @@
+#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:
+ 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();
+ };
+ }
+ }
+} \ No newline at end of file