summaryrefslogtreecommitdiffstats
path: root/tdefifteen/src/gameboard.h
diff options
context:
space:
mode:
authorgregory guy <[email protected]>2020-11-25 15:16:40 +0100
committerSlávek Banko <[email protected]>2020-12-02 19:51:38 +0100
commitd607668c5a772823d6cf59df205b7aa6d2ac2130 (patch)
tree7f8b4d8c5b0f26fed9bc870bea548cac766099a0 /tdefifteen/src/gameboard.h
parentcc192fd9396098134f6aa1369d63c4b270cddfe9 (diff)
downloadtdegames-d607668c5a772823d6cf59df205b7aa6d2ac2130.tar.gz
tdegames-d607668c5a772823d6cf59df205b7aa6d2ac2130.zip
Turn into a TDE application.
The game is renamed TDEFifteen (original name: q15). Add icons (Public Domaine, https://commons.wikimedia.org/wiki/File:15-puzzle.svg). Signed-off-by: gregory guy <[email protected]> (cherry picked from commit e33e8edb80936f8dd04729d70c0c991612340d5e)
Diffstat (limited to 'tdefifteen/src/gameboard.h')
-rw-r--r--tdefifteen/src/gameboard.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/tdefifteen/src/gameboard.h b/tdefifteen/src/gameboard.h
new file mode 100644
index 00000000..55b25e29
--- /dev/null
+++ b/tdefifteen/src/gameboard.h
@@ -0,0 +1,68 @@
+// Author: Denis Kozadaev - (c) 2017-2020
+
+
+#ifndef __GAME_BOARD_H__
+#define __GAME_BOARD_H__
+
+#include <stdlib.h>
+
+#include <tqwidget.h>
+#include <tqlabel.h>
+#include <tqpixmap.h>
+#include <tqtimer.h>
+
+
+class BoardItem:public TQLabel
+{
+public:
+
+ BoardItem(int, TQWidget *parent = NULL, const char *name = NULL);
+ ~BoardItem();
+
+ int item()const{return (num);}
+
+private:
+ int num;
+
+protected:
+ void paintEvent(TQPaintEvent *);
+};
+
+//------------------------------------------------------------------------------
+
+class GameBoard:public TQWidget
+{
+ Q_OBJECT
+public:
+
+ GameBoard(TQWidget *parent = NULL, const char *name = NULL);
+ ~GameBoard();
+
+ void newGame();
+ void loadImage();
+
+private:
+ int n, nt, xt, yt, dx, dy;
+ BoardItem *map[16];
+ TQTimer *tmr;
+ TQPixmap origin;
+
+ void initMap();
+ void startMoving(int, int);
+ void checkEndGame();
+ void newTask();
+
+ int index(int, int);
+ int mayMove(int);
+ int step(int, int);
+ int sign(int);
+
+protected:
+ void resizeEvent(TQResizeEvent *);
+ void mousePressEvent(TQMouseEvent *);
+
+private slots:
+ void moveItem();
+};
+
+#endif /* __GAME_BOARD_H__ */