summaryrefslogtreecommitdiff
path: root/noncore/games/parashoot/helicopter.cpp
Unidiff
Diffstat (limited to 'noncore/games/parashoot/helicopter.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/parashoot/helicopter.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/noncore/games/parashoot/helicopter.cpp b/noncore/games/parashoot/helicopter.cpp
index 0923124..036b21e 100644
--- a/noncore/games/parashoot/helicopter.cpp
+++ b/noncore/games/parashoot/helicopter.cpp
@@ -1,101 +1,107 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "helicopter.h" 21#include "helicopter.h"
22#include "man.h" 22#include "man.h"
23#include "codes.h" 23#include "codes.h"
24 24
25#include <qpe/resource.h> 25#include <qtopia/resource.h>
26 26
27#include <qregexp.h> 27#include <qregexp.h>
28 28
29static QList<Helicopter> all; 29static QList<Helicopter> all;
30 30
31Helicopter::Helicopter(QCanvas* canvas) : 31Helicopter::Helicopter(QCanvas* canvas) :
32 QCanvasSprite(0, canvas), 32 QCanvasSprite(0, canvas),
33 chikachika("aland01") 33 chikachika("aland01")
34{ 34{
35 all.append(this); 35 all.append(this);
36 hits = 0; 36 hits = 0;
37 QCanvasPixmapArray* helicopterarray = new QCanvasPixmapArray(); 37 QCanvasPixmapArray* helicopterarray = new QCanvasPixmapArray();
38 QString h0 = Resource::findPixmap("parashoot/helicopter0001"); 38 QString h0 = Resource::findPixmap("parashoot/helicopter0001");
39 h0.replace(QRegExp("0001"),"%1"); 39 h0.replace(QRegExp("0001"),"%1");
40 helicopterarray->readPixmaps(h0,3 ); 40 helicopterarray->readPixmaps(h0,4 );
41
41 setSequence(helicopterarray); 42 setSequence(helicopterarray);
42 setAnimated(true); 43 setAnimated(true);
43 move(canvas->width(), 5); 44 move(canvas->width(), 5);
44 setVelocity(-2, 0); 45 setVelocity(-2, 0);
45 chikachika.playLoop(); 46 chikachika.playLoop();
46 show(); 47 show();
47} 48}
48 49
49Helicopter::~Helicopter() 50Helicopter::~Helicopter()
50{ 51{
51 all.remove(this); 52 all.remove(this);
52} 53}
53 54
54int fr = 0; 55int fr = 0;
55 56
56void Helicopter::advance(int phase) 57void Helicopter::advance(int phase)
57{ 58{
58 QCanvasSprite::advance(phase); 59 QCanvasSprite::advance(phase);
59 if (phase == 0) { 60 if (phase == 0) {
60 setFrame(fr%3); 61 if (frame() == 3) {
61 fr++; 62 delete this;
62 checkCollision(); 63 return;
64 }
65
66 if (hits >= 2) {
67 setFrame(3);
68 } else {
69 setFrame(fr%3);
70 fr++;
71 checkCollision();
72 }
63 } 73 }
64} 74}
65 75
66void Helicopter::checkCollision() 76void Helicopter::checkCollision()
67{ 77{
68 if (x() == 6) { 78 if (x() == 6) {
69 setAnimated(false); //setVelocity(0, 0); 79 setAnimated(false); //setVelocity(0, 0);
70 dropman(); 80 dropman();
71 } 81 }
72 if (x() < 0) 82 if (x() < 0)
73 done(); 83 done();
74} 84}
75 85
76void Helicopter::dropman() 86void Helicopter::dropman()
77{ 87{
78 (void)new Man(canvas(), 15, 25); 88 (void)new Man(canvas(), 15, 25);
79 (void)new Man(canvas(), 35, 25); 89 (void)new Man(canvas(), 35, 25);
80 takeOff(); 90 takeOff();
81} 91}
82 92
83void Helicopter::done() 93void Helicopter::done()
84{ 94{
85 hits++; 95 hits++;
86 if (hits >= 2) {
87 setAnimated(false);
88 delete this;
89 }
90} 96}
91 97
92void Helicopter::takeOff() 98void Helicopter::takeOff()
93{ 99{
94 setVelocity(-1, 0); 100 setVelocity(-1, 0);
95} 101}
96 102
97int Helicopter::rtti() const 103int Helicopter::rtti() const
98{ 104{
99 return helicopter_rtti; 105 return helicopter_rtti;
100} 106}
101 107