00001 /********************************************************************** 00002 ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 00003 ** 00004 ** This file is part of the 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 #include "codes.h" 00021 #include "base.h" 00022 00023 #include <opie2/oresource.h> 00024 00025 int damage; 00026 00027 Base::Base(QCanvas* canvas) : 00028 QCanvasSprite(0, canvas), 00029 kaboom("landmine"), 00030 ohdear("crmble01") 00031 { 00032 basearray = new QCanvasPixmapArray(); 00033 QString b0 = Opie::Core::OResource::findPixmap("parashoot/b0001"); 00034 b0.replace(QRegExp("0001"),"%1"); 00035 basearray->readPixmaps(b0, 4); 00036 setSequence(basearray); 00037 setFrame(0); 00038 move(2, canvas->height()-50); 00039 setZ(10); 00040 show(); 00041 damage = 0; 00042 } 00043 00044 void Base::damageBase() 00045 { 00046 damage++; 00047 00048 switch(damage) { 00049 case 1: setFrame(1); ohdear.play(); break; 00050 case 2: setFrame(2); ohdear.play(); break; 00051 case 3: setFrame(3); kaboom.play(); break; 00052 } 00053 show(); 00054 } 00055 00056 bool Base::baseDestroyed() 00057 { 00058 return (damage >= 3); 00059 } 00060 00061 Base::~Base() 00062 { 00063 } 00064 00065 int Base::rtti() const 00066 { 00067 return base_rtti; 00068 } 00069 00070 void 00071 Base::reposition(void) 00072 { 00073 move(2, canvas()->height()-50); 00074 }
1.4.2