summaryrefslogtreecommitdiff
path: root/noncore/games/snake/obstacle.cpp
Unidiff
Diffstat (limited to 'noncore/games/snake/obstacle.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/snake/obstacle.cpp35
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
@@ -25,16 +25,35 @@
25 25
26Obstacle::Obstacle(QCanvas* canvas, int x, int y) 26
27 : QCanvasSprite(0, canvas) 27
28Obstacle::Obstacle(QCanvas* canvas, int y)
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") );
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();