Diffstat (limited to 'noncore/games/snake/obstacle.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/snake/obstacle.cpp | 35 |
1 files changed, 27 insertions, 8 deletions
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 | { |