summaryrefslogtreecommitdiff
path: root/noncore/games/snake/snake.h
Unidiff
Diffstat (limited to 'noncore/games/snake/snake.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/snake/snake.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/noncore/games/snake/snake.h b/noncore/games/snake/snake.h
new file mode 100644
index 0000000..5725343
--- a/dev/null
+++ b/noncore/games/snake/snake.h
@@ -0,0 +1,64 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#include <qcanvas.h>
21#include <qtimer.h>
22
23class Snake : public QObject
24{
25 Q_OBJECT
26
27public:
28 enum Direction{ left, right, up, down};
29
30 Snake(QCanvas*);
31 ~Snake();
32 void go(int newkey);
33 void move(Direction dir);
34 void changeHead(int last);
35 void changeTail();
36 void detectCrash();
37 void createSnake();
38 void extendSnake();
39 int lookUpPiece(Direction currentdir, Direction newdir);
40 void setScore(int amount);
41 int getScore();
42
43signals:
44 void dead();
45 void targethit();
46 void scorechanged();
47
48private slots:
49 void moveSnake();
50 void increaseSpeed();
51
52private:
53 QCanvasPixmapArray* snakeparts;
54 QList<QCanvasSprite>snakelist;
55 QTimer* autoMoveTimer;
56 QCanvas* canvas;
57 int grow;
58 int last;
59 int speed;
60 int score;
61 Direction currentdir;
62 Direction newdir;
63};
64