00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "obstacle.h"
00022 #include "codes.h"
00023
00024 #include <opie2/oresource.h>
00025
00026 Obstacle::Obstacle(QCanvas* canvas, int y)
00027 : QCanvasSprite(0,canvas)
00028 {
00029 newObstacle(y);
00030 }
00031
00032 void Obstacle::newObstacle(int y)
00033 {
00034 QPixmap obstaclePix( Opie::Core::OResource::findPixmap("snake/wall") );
00035
00036 if ( obstaclePix.width() > canvas()->width()*3/5 ) {
00037 int w = canvas()->width()*3/5;
00038 w = w - w % 16;
00039 obstaclePix.resize( w, obstaclePix.height() );
00040 }
00041
00042 QList<QPixmap> pixl;
00043 pixl.append( &obstaclePix );
00044
00045 QPoint nullp;
00046 QList<QPoint> pl;
00047 pl.append( &nullp );
00048
00049 QCanvasPixmapArray* obstaclearray = new QCanvasPixmapArray(pixl, pl);
00050 setSequence(obstaclearray);
00051
00052 int x = ( canvas()->width() - obstaclePix.width() )/2;
00053 x = x - x % 16;
00054 y = y - y % 16;
00055 move(x, y);
00056 setZ( -100 );
00057 show();
00058 canvas()->update();
00059 }
00060
00061 int Obstacle::rtti() const
00062 {
00063 return obstacle_rtti;
00064 }
00065
00066 Obstacle::~Obstacle()
00067 {
00068 }