author | kergoth <kergoth> | 2002-06-07 18:53:14 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-06-07 18:53:14 (UTC) |
commit | 640d964cfdc7467f6cacb513087cd3acda2c04f0 (patch) (unidiff) | |
tree | 9a784686c1795f8b1f81eb344598f3b549d43467 /noncore/games/snake | |
parent | dfb9c76738bb68e235114c5ad43dbd26a59b98ab (diff) | |
download | opie-640d964cfdc7467f6cacb513087cd3acda2c04f0.zip opie-640d964cfdc7467f6cacb513087cd3acda2c04f0.tar.gz opie-640d964cfdc7467f6cacb513087cd3acda2c04f0.tar.bz2 |
Backing out unintentional merge from TT branch.
-rw-r--r-- | noncore/games/snake/interface.h | 2 | ||||
-rw-r--r-- | noncore/games/snake/obstacle.cpp | 35 | ||||
-rw-r--r-- | noncore/games/snake/obstacle.h | 4 |
3 files changed, 30 insertions, 11 deletions
diff --git a/noncore/games/snake/interface.h b/noncore/games/snake/interface.h index 30c7f84..454d4ee 100644 --- a/noncore/games/snake/interface.h +++ b/noncore/games/snake/interface.h | |||
@@ -33,13 +33,12 @@ class SnakeGame : public QMainWindow { | |||
33 | public: | 33 | public: |
34 | SnakeGame(QWidget* parent=0, const char* name=0, WFlags f=0); | 34 | SnakeGame(QWidget* parent=0, const char* name=0, WFlags f=0); |
35 | ~SnakeGame(); | 35 | ~SnakeGame(); |
36 | 36 | ||
37 | void clear(); | 37 | void clear(); |
38 | void createTargets(); | 38 | void createTargets(); |
39 | void welcomescreen(); | ||
40 | 39 | ||
41 | protected: | 40 | protected: |
42 | virtual void keyPressEvent(QKeyEvent*); | 41 | virtual void keyPressEvent(QKeyEvent*); |
43 | virtual void resizeEvent(QResizeEvent *e); | 42 | virtual void resizeEvent(QResizeEvent *e); |
44 | 43 | ||
45 | signals: | 44 | signals: |
@@ -48,12 +47,13 @@ signals: | |||
48 | private slots: | 47 | private slots: |
49 | void newGame(); | 48 | void newGame(); |
50 | void gameOver(); | 49 | void gameOver(); |
51 | void wait(); | 50 | void wait(); |
52 | void levelUp(); | 51 | void levelUp(); |
53 | void scoreInc(); | 52 | void scoreInc(); |
53 | void welcomescreen(); | ||
54 | 54 | ||
55 | private: | 55 | private: |
56 | void showScore(int); | 56 | void showScore(int); |
57 | QCanvasView* cv; | 57 | QCanvasView* cv; |
58 | QLabel* scorelabel; | 58 | QLabel* scorelabel; |
59 | QCanvas canvas; | 59 | QCanvas canvas; |
diff --git a/noncore/games/snake/obstacle.cpp b/noncore/games/snake/obstacle.cpp index 2d07fe7..4bdefa5 100644 --- a/noncore/games/snake/obstacle.cpp +++ b/noncore/games/snake/obstacle.cpp | |||
@@ -20,26 +20,45 @@ | |||
20 | 20 | ||
21 | #include "obstacle.h" | 21 | #include "obstacle.h" |
22 | #include "codes.h" | 22 | #include "codes.h" |
23 | 23 | ||
24 | #include <qpe/resource.h> | 24 | #include <qpe/resource.h> |
25 | 25 | ||
26 | Obstacle::Obstacle(QCanvas* canvas, int x, int y) | 26 | |
27 | : QCanvasSprite(0, canvas) | 27 | |
28 | Obstacle::Obstacle(QCanvas* canvas, int y) | ||
29 | : QCanvasSprite(0,canvas) | ||
28 | { | 30 | { |
29 | newObstacle(x, y); | 31 | newObstacle(y); |
30 | } | 32 | } |
31 | 33 | ||
32 | void Obstacle::newObstacle(int x, int y) | 34 | void Obstacle::newObstacle(int y) |
33 | { | 35 | { |
34 | QCanvasPixmapArray* obstaclearray = new QCanvasPixmapArray(Resource::findPixmap("snake/wall.png")); | 36 | QPixmap obstaclePix( Resource::findPixmap("snake/wall.png") ); |
35 | 37 | ||
38 | if ( obstaclePix.width() > canvas()->width()*3/5 ) { | ||
39 | int w = canvas()->width()*3/5; | ||
40 | w = w - w % 16; | ||
41 | obstaclePix.resize( w, obstaclePix.height() ); | ||
42 | } | ||
43 | |||
44 | QList<QPixmap> pixl; | ||
45 | pixl.append( &obstaclePix ); | ||
46 | |||
47 | QPoint nullp; | ||
48 | QList<QPoint> pl; | ||
49 | pl.append( &nullp ); | ||
50 | |||
51 | QCanvasPixmapArray* obstaclearray = new QCanvasPixmapArray(pixl, pl); | ||
36 | setSequence(obstaclearray); | 52 | setSequence(obstaclearray); |
37 | 53 | ||
54 | int x = ( canvas()->width() - obstaclePix.width() )/2; | ||
55 | x = x - x % 16; | ||
56 | y = y - y % 16; | ||
38 | move(x, y); | 57 | move(x, y); |
39 | 58 | setZ( -100 ); | |
40 | show(); | 59 | show(); |
41 | canvas()->update(); | 60 | canvas()->update(); |
42 | } | 61 | } |
43 | 62 | ||
44 | int Obstacle::rtti() const | 63 | int Obstacle::rtti() const |
45 | { | 64 | { |
diff --git a/noncore/games/snake/obstacle.h b/noncore/games/snake/obstacle.h index 838917f..b3c7846 100644 --- a/noncore/games/snake/obstacle.h +++ b/noncore/games/snake/obstacle.h | |||
@@ -20,11 +20,11 @@ | |||
20 | #include <qcanvas.h> | 20 | #include <qcanvas.h> |
21 | 21 | ||
22 | class Obstacle : public QCanvasSprite | 22 | class Obstacle : public QCanvasSprite |
23 | { | 23 | { |
24 | 24 | ||
25 | public: | 25 | public: |
26 | Obstacle(QCanvas*, int x, int y); | 26 | Obstacle(QCanvas*, int y); |
27 | ~Obstacle(); | 27 | ~Obstacle(); |
28 | void newObstacle(int x, int y); | 28 | void newObstacle(int y); |
29 | int rtti() const; | 29 | int rtti() const; |
30 | }; | 30 | }; |