From 12617ed1bf0738970c1ccf32d0b523e6d5999531 Mon Sep 17 00:00:00 2001 From: Jed Date: Sat, 2 Jan 2021 14:08:12 -0600 Subject: adds 2048 clone game styles table reads touch events allows moving tiles allows merging tiles improves tile movement allows merging tiles adds score display implements color edit comments adjust game logic disallows double merges --- src/displayapp/screens/Twos.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/displayapp/screens/Twos.h (limited to 'src/displayapp/screens/Twos.h') 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 +#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 -- cgit v1.2.3-70-g09d2