aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-03-19 12:18:52 +0100
committerCharles <sircharlesaze@gmail.com>2020-03-19 12:18:52 +0100
commitc435852cc6147a0af23ef12cc0a07a195ac60756 (patch)
tree46797e58189fca8946f752ed20c24e2ccf609f32 /include
parentce65a7e1f682fa31934c05623c41ea25d9b71ce7 (diff)
download2048-c435852cc6147a0af23ef12cc0a07a195ac60756.tar.gz
2048-c435852cc6147a0af23ef12cc0a07a195ac60756.tar.bz2
2048-c435852cc6147a0af23ef12cc0a07a195ac60756.zip
Added score
Diffstat (limited to 'include')
-rw-r--r--include/game.hpp2
-rw-r--r--include/graphics.hpp8
2 files changed, 8 insertions, 2 deletions
diff --git a/include/game.hpp b/include/game.hpp
index 550b47a..62a024c 100644
--- a/include/game.hpp
+++ b/include/game.hpp
@@ -12,6 +12,7 @@ class Game
Game(int s);
~Game();
int getSize();
+ int getScore();
int at(int x, int y);
void move(Direction direction);
void spawn();
@@ -20,6 +21,7 @@ class Game
private:
int size;
int **grid;
+ int score;
void mergeRow(std::vector<int> &row);
int **gridCopy();
bool gridEqual(int **other);
diff --git a/include/graphics.hpp b/include/graphics.hpp
index ccebdae..ebb596b 100644
--- a/include/graphics.hpp
+++ b/include/graphics.hpp
@@ -19,8 +19,6 @@ class Graphics
~Graphics();
void update();
- void drawGame();
- void drawCell(int x, int y);
bool isRunning();
private:
@@ -28,16 +26,22 @@ class Graphics
std::string title;
int width;
int height;
+ int gridSize;
Game *game;
SDL_Renderer *renderer;
SDL_Window *window;
TTF_Font *font;
+ SDL_Texture *scoreText;
std::vector< std::pair<int, SDL_Texture*> > numberTexBuf;
std::map< int, SDL_Color > palette;
+ void drawGame();
+ void drawCell(int x, int y);
+ void drawScore();
void handleEvent();
SDL_Texture *addNumberTex(int n);
SDL_Texture *getNumberTex(int n);
+ SDL_Texture *newTextTex(std::string s, SDL_Color c);
void error();
};