Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

obstacle.cpp

Go to the documentation of this file.
00001 /**********************************************************************
00002 ** Copyright (C) 2000 Trolltech AS.  All rights reserved.
00003 **
00004 ** This file is part of Qtopia Environment.
00005 **
00006 ** This file may be distributed and/or modified under the terms of the
00007 ** GNU General Public License version 2 as published by the Free Software
00008 ** Foundation and appearing in the file LICENSE.GPL included in the
00009 ** packaging of this file.
00010 **
00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00013 **
00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00015 **
00016 ** Contact info@trolltech.com if any conditions of this licensing are
00017 ** not clear to you.
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 }

Generated on Sat Nov 5 16:17:25 2005 for OPIE by  doxygen 1.4.2