-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 | |||
@@ -37,5 +37,4 @@ public: | |||
37 | void clear(); | 37 | void clear(); |
38 | void createTargets(); | 38 | void createTargets(); |
39 | void welcomescreen(); | ||
40 | 39 | ||
41 | protected: | 40 | protected: |
@@ -52,4 +51,5 @@ private slots: | |||
52 | void levelUp(); | 51 | void levelUp(); |
53 | void scoreInc(); | 52 | void scoreInc(); |
53 | void welcomescreen(); | ||
54 | 54 | ||
55 | private: | 55 | private: |
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 | |||
@@ -24,18 +24,37 @@ | |||
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(); |
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 | |||
@@ -24,7 +24,7 @@ class Obstacle : public QCanvasSprite | |||
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 | }; |