Diffstat (limited to 'noncore/games/parashoot/cannon.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/parashoot/cannon.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/noncore/games/parashoot/cannon.cpp b/noncore/games/parashoot/cannon.cpp index 3c0a5fe..5671351 100644 --- a/noncore/games/parashoot/cannon.cpp +++ b/noncore/games/parashoot/cannon.cpp | |||
@@ -1,60 +1,59 @@ | |||
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 <qpe/resource.h> | 21 | #include <qtopia/resource.h> |
22 | 22 | ||
23 | #include <qregexp.h> | 23 | #include <qregexp.h> |
24 | 24 | ||
25 | #include "codes.h" | 25 | #include "codes.h" |
26 | #include "cannon.h" | 26 | #include "cannon.h" |
27 | 27 | ||
28 | Cannon::Cannon(QCanvas* canvas) : | 28 | Cannon::Cannon(QCanvas* canvas) : |
29 | QCanvasSprite(0, canvas) | 29 | QCanvasSprite(0, canvas) |
30 | { | 30 | { |
31 | shotsfired=0; | 31 | shotsfired=0; |
32 | index = 8; | 32 | index = 8; |
33 | cannonx = 0; | 33 | cannonx = 0; |
34 | cannony = 0; | 34 | cannony = 0; |
35 | cannonarray = new QCanvasPixmapArray(); | 35 | cannonarray = new QCanvasPixmapArray(); |
36 | QString c0 = Resource::findPixmap("parashoot/can0001"); | 36 | QString c0 = Resource::findPixmap("parashoot/can0001"); |
37 | c0.replace(QRegExp("0001"),"%1"); | 37 | c0.replace(QRegExp("0001"),"%1"); |
38 | cannonarray->readPixmaps(c0,17); | 38 | cannonarray->readPixmaps(c0,17); |
39 | setSequence(cannonarray); | 39 | setSequence(cannonarray); |
40 | setFrame(index); | 40 | setFrame(index); |
41 | move(canvas->width()/2-20, canvas->height()-32); | 41 | |
42 | // co ords for barrel of cannon when upright | 42 | reposition(); |
43 | barrelypos = canvas->height()-32; | 43 | |
44 | barrelxpos = canvas->width()/2; | ||
45 | movedir = NoDir; | 44 | movedir = NoDir; |
46 | moveDelay = 0; | 45 | moveDelay = 0; |
47 | setAnimated(TRUE); | 46 | setAnimated(TRUE); |
48 | show(); | 47 | show(); |
49 | } | 48 | } |
50 | 49 | ||
51 | void Cannon::advance(int stage) | 50 | void Cannon::advance(int stage) |
52 | { | 51 | { |
53 | if ( stage == 1 && moveDelay-- == 0 ) { | 52 | if ( stage == 1 && moveDelay-- == 0 ) { |
54 | if (movedir == Left) { | 53 | if (movedir == Left) { |
55 | if (index > 0) { | 54 | if (index > 0) { |
56 | setFrame(index-1); | 55 | setFrame(index-1); |
57 | index--; | 56 | index--; |
58 | } | 57 | } |
59 | } | 58 | } |
60 | if (movedir == Right) { | 59 | if (movedir == Right) { |
@@ -125,16 +124,27 @@ double Cannon::shootAngle() | |||
125 | void Cannon::shoot() | 124 | void Cannon::shoot() |
126 | { | 125 | { |
127 | setCoords(); | 126 | setCoords(); |
128 | Bullet* bullet = new Bullet(canvas(), shootAngle(), cannonx, cannony); | 127 | Bullet* bullet = new Bullet(canvas(), shootAngle(), cannonx, cannony); |
129 | connect(bullet, SIGNAL(score(int)), this, SIGNAL(score(int))); | 128 | connect(bullet, SIGNAL(score(int)), this, SIGNAL(score(int))); |
130 | shotsfired++; | 129 | shotsfired++; |
131 | } | 130 | } |
132 | 131 | ||
133 | Cannon::~Cannon() | 132 | Cannon::~Cannon() |
134 | { | 133 | { |
135 | } | 134 | } |
136 | 135 | ||
137 | int Cannon::rtti() const | 136 | int Cannon::rtti() const |
138 | { | 137 | { |
139 | return cannon_rtti; | 138 | return cannon_rtti; |
140 | } | 139 | } |
140 | |||
141 | void Cannon::reposition(void) | ||
142 | { | ||
143 | move(canvas()->width()/2-20, canvas()->height()-32); | ||
144 | // co ords for barrel of cannon when upright | ||
145 | barrelypos = canvas()->height()-32; | ||
146 | barrelxpos = canvas()->width()/2; | ||
147 | |||
148 | setFrame(index); | ||
149 | setCoords(); | ||
150 | } | ||