summaryrefslogtreecommitdiff
path: root/noncore/games/snake
Unidiff
Diffstat (limited to 'noncore/games/snake') (more/less context) (show whitespace changes)
-rw-r--r--noncore/games/snake/interface.h2
-rw-r--r--noncore/games/snake/obstacle.cpp29
-rw-r--r--noncore/games/snake/obstacle.h4
3 files changed, 27 insertions, 8 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
@@ -38,3 +38,2 @@ public:
38 void createTargets(); 38 void createTargets();
39 void welcomescreen();
40 39
@@ -53,2 +52,3 @@ private slots:
53 void scoreInc(); 52 void scoreInc();
53 void welcomescreen();
54 54
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
@@ -25,16 +25,35 @@
25 25
26Obstacle::Obstacle(QCanvas* canvas, int x, int y) 26
27
28Obstacle::Obstacle(QCanvas* canvas, int y)
27 : QCanvasSprite(0, canvas) 29 : QCanvasSprite(0, canvas)
28{ 30{
29 newObstacle(x, y); 31 newObstacle(y);
30} 32}
31 33
32void Obstacle::newObstacle(int x, int y) 34void Obstacle::newObstacle(int y)
33{ 35{
34 QCanvasPixmapArray* obstaclearray = new QCanvasPixmapArray(Resource::findPixmap("snake/wall.png")); 36 QPixmap obstaclePix( Resource::findPixmap("snake/wall.png") );
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 }
35 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();
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
@@ -25,5 +25,5 @@ class Obstacle : public QCanvasSprite
25public: 25public:
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;