-rw-r--r-- | noncore/games/parashoot/base.cpp | 12 | ||||
-rw-r--r-- | noncore/games/parashoot/base.h | 8 | ||||
-rw-r--r-- | noncore/games/parashoot/cannon.cpp | 24 | ||||
-rw-r--r-- | noncore/games/parashoot/cannon.h | 6 | ||||
-rw-r--r-- | noncore/games/parashoot/helicopter.cpp | 28 | ||||
-rw-r--r-- | noncore/games/parashoot/helicopter.h | 6 | ||||
-rw-r--r-- | noncore/games/parashoot/interface.cpp | 74 | ||||
-rw-r--r-- | noncore/games/parashoot/interface.h | 22 | ||||
-rw-r--r-- | noncore/games/parashoot/man.cpp | 39 |
9 files changed, 148 insertions, 71 deletions
diff --git a/noncore/games/parashoot/base.cpp b/noncore/games/parashoot/base.cpp index c03802f..cdf1dfa 100644 --- a/noncore/games/parashoot/base.cpp +++ b/noncore/games/parashoot/base.cpp | |||
@@ -1,7 +1,7 @@ | |||
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 |
@@ -21,7 +21,7 @@ | |||
21 | #include "base.h" | 21 | #include "base.h" |
22 | #include "man.h" | 22 | #include "man.h" |
23 | 23 | ||
24 | #include <qpe/resource.h> | 24 | #include <qtopia/resource.h> |
25 | 25 | ||
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | 27 | ||
@@ -69,3 +69,9 @@ int Base::rtti() const | |||
69 | { | 69 | { |
70 | return base_rtti; | 70 | return base_rtti; |
71 | } | 71 | } |
72 | |||
73 | void | ||
74 | Base::reposition(void) | ||
75 | { | ||
76 | move(2, canvas()->height()-50); | ||
77 | } | ||
diff --git a/noncore/games/parashoot/base.h b/noncore/games/parashoot/base.h index ee7f166..a4c69cc 100644 --- a/noncore/games/parashoot/base.h +++ b/noncore/games/parashoot/base.h | |||
@@ -1,7 +1,7 @@ | |||
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 |
@@ -18,7 +18,7 @@ | |||
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <qpe/sound.h> | 21 | #include <qtopia/sound.h> |
22 | 22 | ||
23 | #include <qcanvas.h> | 23 | #include <qcanvas.h> |
24 | 24 | ||
@@ -32,6 +32,8 @@ public: | |||
32 | int rtti() const; | 32 | int rtti() const; |
33 | static bool baseDestroyed(); | 33 | static bool baseDestroyed(); |
34 | 34 | ||
35 | void reposition(void); | ||
36 | |||
35 | private: | 37 | private: |
36 | QCanvasPixmapArray* basearray; | 38 | QCanvasPixmapArray* basearray; |
37 | Sound kaboom, ohdear; | 39 | Sound kaboom, ohdear; |
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,7 +1,7 @@ | |||
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 |
@@ -18,7 +18,7 @@ | |||
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 | ||
@@ -38,10 +38,9 @@ shotsfired=0; | |||
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); |
@@ -138,3 +137,14 @@ 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 | } | ||
diff --git a/noncore/games/parashoot/cannon.h b/noncore/games/parashoot/cannon.h index 44d0c65..51b1247 100644 --- a/noncore/games/parashoot/cannon.h +++ b/noncore/games/parashoot/cannon.h | |||
@@ -1,7 +1,7 @@ | |||
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 |
@@ -39,6 +39,8 @@ public: | |||
39 | 39 | ||
40 | int shotsFired() { return shotsfired; }; | 40 | int shotsFired() { return shotsfired; }; |
41 | 41 | ||
42 | void reposition(void); | ||
43 | |||
42 | protected: | 44 | protected: |
43 | void advance(int stage); | 45 | void advance(int stage); |
44 | 46 | ||
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,7 +1,7 @@ | |||
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 |
@@ -22,7 +22,7 @@ | |||
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 | ||
@@ -37,7 +37,8 @@ Helicopter::Helicopter(QCanvas* canvas) : | |||
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); |
@@ -57,9 +58,18 @@ void 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 | ||
@@ -83,10 +93,6 @@ void Helicopter::dropman() | |||
83 | void Helicopter::done() | 93 | void Helicopter::done() |
84 | { | 94 | { |
85 | hits++; | 95 | hits++; |
86 | if (hits >= 2) { | ||
87 | setAnimated(false); | ||
88 | delete this; | ||
89 | } | ||
90 | } | 96 | } |
91 | 97 | ||
92 | void Helicopter::takeOff() | 98 | void Helicopter::takeOff() |
diff --git a/noncore/games/parashoot/helicopter.h b/noncore/games/parashoot/helicopter.h index 5cb92de..954c651 100644 --- a/noncore/games/parashoot/helicopter.h +++ b/noncore/games/parashoot/helicopter.h | |||
@@ -1,7 +1,7 @@ | |||
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 |
@@ -18,7 +18,7 @@ | |||
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <qpe/sound.h> | 21 | #include <qtopia/sound.h> |
22 | 22 | ||
23 | #include <qcanvas.h> | 23 | #include <qcanvas.h> |
24 | 24 | ||
diff --git a/noncore/games/parashoot/interface.cpp b/noncore/games/parashoot/interface.cpp index a40426d..948b92c 100644 --- a/noncore/games/parashoot/interface.cpp +++ b/noncore/games/parashoot/interface.cpp | |||
@@ -1,7 +1,7 @@ | |||
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 |
@@ -21,27 +21,31 @@ | |||
21 | #include "interface.h" | 21 | #include "interface.h" |
22 | #include "man.h" | 22 | #include "man.h" |
23 | 23 | ||
24 | #include <qpe/resource.h> | 24 | #include <qtopia/qpeapplication.h> |
25 | #include <qpe/qpeapplication.h> | 25 | #include <qtopia/resource.h> |
26 | 26 | ||
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qmessagebox.h> | 28 | #include <qmessagebox.h> |
29 | #include <qapplication.h> | 29 | #include <qapplication.h> |
30 | #include <qstyle.h> | 30 | #include <qstyle.h> |
31 | #include <qpe/qpetoolbar.h> | 31 | #include <qtoolbar.h> |
32 | #include <qtoolbutton.h> | 32 | #include <qtoolbutton.h> |
33 | 33 | ||
34 | ParaShoot::ParaShoot(QWidget* parent, const char* name, WFlags f) : | 34 | ParaShoot::ParaShoot(QWidget* parent, const char* name, WFlags f) : |
35 | QMainWindow(parent,name,f), | 35 | QMainWindow(parent,name,f), |
36 | canvas(232, 258), | 36 | canvas( 232, 258 ), |
37 | cannon(NULL), | ||
38 | base(NULL), | ||
39 | gamestopped( true ), | ||
40 | waitover( false ), | ||
37 | fanfare("level_up"), | 41 | fanfare("level_up"), |
38 | score(0) | 42 | score(0) |
39 | { | 43 | { |
40 | QPEApplication::grabKeyboard(); | 44 | QPEApplication::grabKeyboard(); |
41 | QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff ); | 45 | QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff ); |
46 | |||
47 | updatespeed = 80; | ||
42 | canvas.setAdvancePeriod(80); | 48 | canvas.setAdvancePeriod(80); |
43 | QPixmap bg = Resource::loadPixmap("parashoot/sky"); | ||
44 | canvas.setBackgroundPixmap(bg); | ||
45 | 49 | ||
46 | pb = new QCanvasView(&canvas, this); | 50 | pb = new QCanvasView(&canvas, this); |
47 | pb->setFocus(); | 51 | pb->setFocus(); |
@@ -52,9 +56,7 @@ ParaShoot::ParaShoot(QWidget* parent, const char* name, WFlags f) : | |||
52 | toolbar->setHorizontalStretchable( TRUE ); | 56 | toolbar->setHorizontalStretchable( TRUE ); |
53 | 57 | ||
54 | setCaption( tr("ParaShoot") ); | 58 | setCaption( tr("ParaShoot") ); |
55 | QPixmap newicon = Resource::loadPixmap("parashoot/manicon"); | 59 | new QToolButton( Resource::loadIconSet("new"), tr("New Game"), 0, |
56 | setIcon(newicon); | ||
57 | new QToolButton(newicon, tr("New Game"), 0, | ||
58 | this, SLOT(newGame()), toolbar, "New Game"); | 60 | this, SLOT(newGame()), toolbar, "New Game"); |
59 | 61 | ||
60 | levelscore = new QLabel(toolbar); | 62 | levelscore = new QLabel(toolbar); |
@@ -72,8 +74,6 @@ ParaShoot::ParaShoot(QWidget* parent, const char* name, WFlags f) : | |||
72 | connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) ); | 74 | connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) ); |
73 | 75 | ||
74 | setFocusPolicy(StrongFocus); | 76 | setFocusPolicy(StrongFocus); |
75 | |||
76 | newGame(); | ||
77 | } | 77 | } |
78 | 78 | ||
79 | 79 | ||
@@ -82,8 +82,34 @@ void ParaShoot::resizeEvent(QResizeEvent *) | |||
82 | QSize s = centralWidget()->size(); | 82 | QSize s = centralWidget()->size(); |
83 | int fw = style().defaultFrameWidth(); | 83 | int fw = style().defaultFrameWidth(); |
84 | canvas.resize( s.width() - fw - 2, s.height() - fw - 2); | 84 | canvas.resize( s.width() - fw - 2, s.height() - fw - 2); |
85 | |||
86 | QImage bgimage = Resource::loadImage("parashoot/sky"); | ||
87 | QPixmap bgpixmap; | ||
88 | |||
89 | bgpixmap.convertFromImage(bgimage.smoothScale(canvas.width(), | ||
90 | canvas.height()), QPixmap::Auto); | ||
91 | canvas.setBackgroundPixmap(bgpixmap); | ||
92 | |||
93 | if (base) { | ||
94 | base->reposition(); | ||
95 | } | ||
96 | |||
97 | if (cannon) { | ||
98 | cannon->reposition(); | ||
99 | } | ||
85 | } | 100 | } |
86 | 101 | ||
102 | void ParaShoot::focusOutEvent (QFocusEvent *) | ||
103 | { | ||
104 | if (!gamestopped) | ||
105 | canvas.setAdvancePeriod(-1); | ||
106 | } | ||
107 | |||
108 | void ParaShoot::focusInEvent (QFocusEvent *) | ||
109 | { | ||
110 | if (!gamestopped) | ||
111 | canvas.setAdvancePeriod(updatespeed); | ||
112 | } | ||
87 | 113 | ||
88 | void ParaShoot::showScore( int score, int level ) | 114 | void ParaShoot::showScore( int score, int level ) |
89 | { | 115 | { |
@@ -150,8 +176,9 @@ void ParaShoot::gameOver() | |||
150 | " Accuracy: %3% " ).arg(score).arg(shots).arg(shots * 100 / shotsFired ), | 176 | " Accuracy: %3% " ).arg(score).arg(shots).arg(shots * 100 / shotsFired ), |
151 | &canvas); | 177 | &canvas); |
152 | gameover->setColor(red); | 178 | gameover->setColor(red); |
153 | gameover->setFont( QFont("times", 18, QFont::Bold) ); | 179 | gameover->setFont( QFont("times", 16, QFont::Bold) ); |
154 | gameover->move(canvas.width()/2 -110, canvas.height()/2 -50); | 180 | gameover->move((canvas.width() - gameover->boundingRect().width()) / 2, |
181 | (canvas.height() - gameover->boundingRect().height()) / 2); | ||
155 | gameover->setZ(500); | 182 | gameover->setZ(500); |
156 | gameover->show(); | 183 | gameover->show(); |
157 | gamestopped = true; | 184 | gamestopped = true; |
@@ -227,16 +254,21 @@ void ParaShoot::keyPressEvent(QKeyEvent* event) | |||
227 | case Key_F1: | 254 | case Key_F1: |
228 | case Key_F9: | 255 | case Key_F9: |
229 | case Key_Space: | 256 | case Key_Space: |
230 | cannon->shoot(); | 257 | if ( cannon ) |
258 | cannon->shoot(); | ||
231 | break; | 259 | break; |
232 | case Key_Left: | 260 | case Key_Left:{ |
233 | cannon->pointCannon(Cannon::Left); | 261 | if (cannon ) |
262 | cannon->pointCannon(Cannon::Left); | ||
234 | lastcannonkey=Key_Left; | 263 | lastcannonkey=Key_Left; |
235 | break; | 264 | break; |
236 | case Key_Right: | 265 | } |
237 | cannon->pointCannon(Cannon::Right); | 266 | case Key_Right:{ |
267 | if ( cannon ) | ||
268 | cannon->pointCannon(Cannon::Right); | ||
238 | lastcannonkey=Key_Right; | 269 | lastcannonkey=Key_Right; |
239 | break; | 270 | break; |
271 | } | ||
240 | default: | 272 | default: |
241 | return; | 273 | return; |
242 | } | 274 | } |
@@ -245,6 +277,6 @@ void ParaShoot::keyPressEvent(QKeyEvent* event) | |||
245 | 277 | ||
246 | void ParaShoot::keyReleaseEvent(QKeyEvent* event) | 278 | void ParaShoot::keyReleaseEvent(QKeyEvent* event) |
247 | { | 279 | { |
248 | if ( lastcannonkey == event->key() ) | 280 | if ( cannon && lastcannonkey == event->key() ) |
249 | cannon->pointCannon(Cannon::NoDir); | 281 | cannon->pointCannon(Cannon::NoDir); |
250 | } | 282 | } |
diff --git a/noncore/games/parashoot/interface.h b/noncore/games/parashoot/interface.h index 5abbe0b..dd73f53 100644 --- a/noncore/games/parashoot/interface.h +++ b/noncore/games/parashoot/interface.h | |||
@@ -1,7 +1,7 @@ | |||
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 |
@@ -22,7 +22,7 @@ | |||
22 | #include "base.h" | 22 | #include "base.h" |
23 | #include "helicopter.h" | 23 | #include "helicopter.h" |
24 | 24 | ||
25 | #include <qpe/sound.h> | 25 | #include <qtopia/sound.h> |
26 | 26 | ||
27 | #include <qmainwindow.h> | 27 | #include <qmainwindow.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
@@ -32,15 +32,16 @@ class QCanvas; | |||
32 | class Helicopter; | 32 | class Helicopter; |
33 | 33 | ||
34 | //enum Direction{ | 34 | //enum Direction{ |
35 | // left, right, up, down }; | 35 | // left, right, up, down }; |
36 | 36 | ||
37 | class ParaShoot : public QMainWindow { | 37 | class ParaShoot : public QMainWindow { |
38 | Q_OBJECT | 38 | Q_OBJECT |
39 | 39 | ||
40 | public: | 40 | public: |
41 | static QString appName() { return QString::fromLatin1("parashoot"); } | ||
42 | ParaShoot(QWidget* parent=0, const char* name=0, WFlags f=0); | 41 | ParaShoot(QWidget* parent=0, const char* name=0, WFlags f=0); |
43 | 42 | static QString appName() { | |
43 | return QString::fromLatin1("parashoot"); | ||
44 | } | ||
44 | void clear(); | 45 | void clear(); |
45 | void gameOver(); | 46 | void gameOver(); |
46 | int mancount; | 47 | int mancount; |
@@ -51,7 +52,9 @@ protected: | |||
51 | virtual void keyPressEvent(QKeyEvent*); | 52 | virtual void keyPressEvent(QKeyEvent*); |
52 | virtual void keyReleaseEvent(QKeyEvent*); | 53 | virtual void keyReleaseEvent(QKeyEvent*); |
53 | virtual void resizeEvent(QResizeEvent *e); | 54 | virtual void resizeEvent(QResizeEvent *e); |
54 | 55 | virtual void focusOutEvent(QFocusEvent *); | |
56 | virtual void focusInEvent(QFocusEvent *); | ||
57 | |||
55 | private slots: | 58 | private slots: |
56 | void increaseScore(int); | 59 | void increaseScore(int); |
57 | void newGame(); | 60 | void newGame(); |
@@ -64,7 +67,6 @@ private: | |||
64 | QCanvas canvas; | 67 | QCanvas canvas; |
65 | Cannon* cannon; | 68 | Cannon* cannon; |
66 | Base* base; | 69 | Base* base; |
67 | QCanvasText* gameover; | ||
68 | QLabel* levelscore; | 70 | QLabel* levelscore; |
69 | int nomen; | 71 | int nomen; |
70 | int level; | 72 | int level; |
@@ -77,4 +79,4 @@ private: | |||
77 | Sound fanfare; | 79 | Sound fanfare; |
78 | int score; | 80 | int score; |
79 | int lastcannonkey; | 81 | int lastcannonkey; |
80 | }; | 82 | }; |
diff --git a/noncore/games/parashoot/man.cpp b/noncore/games/parashoot/man.cpp index 8435572..94807c2 100644 --- a/noncore/games/parashoot/man.cpp +++ b/noncore/games/parashoot/man.cpp | |||
@@ -1,7 +1,7 @@ | |||
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 |
@@ -18,11 +18,11 @@ | |||
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "codes.h" | 21 | #include "codes.h" |
22 | #include "man.h" | 22 | #include "man.h" |
23 | #include "base.h" | 23 | #include "base.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 | ||
@@ -30,12 +30,12 @@ int mancount; | |||
30 | 30 | ||
31 | Man::Man(QCanvas* canvas) : | 31 | Man::Man(QCanvas* canvas) : |
32 | QCanvasSprite(0, canvas), | 32 | QCanvasSprite(0, canvas), |
33 | splat("lose") | 33 | splat("lose") // No tr |
34 | { | 34 | { |
35 | manarray = new QCanvasPixmapArray(); | 35 | manarray = new QCanvasPixmapArray(); |
36 | QString m0 = Resource::findPixmap("parashoot/man0001"); | 36 | QString m0 = Resource::findPixmap("parashoot/man0001"); |
37 | m0.replace(QRegExp("0001"),"%1"); | 37 | m0.replace(QRegExp("0001"),"%1"); |
38 | manarray->readPixmaps(m0, 7); | 38 | manarray->readPixmaps(m0, 7); |
39 | setSequence(manarray); | 39 | setSequence(manarray); |
40 | setAnimated(true); | 40 | setAnimated(true); |
41 | mancount++; | 41 | mancount++; |
@@ -45,7 +45,7 @@ Man::Man(QCanvas* canvas) : | |||
45 | 45 | ||
46 | Man::Man(QCanvas* canvas, int x, int y) : | 46 | Man::Man(QCanvas* canvas, int x, int y) : |
47 | QCanvasSprite(0, canvas), | 47 | QCanvasSprite(0, canvas), |
48 | splat("bang") | 48 | splat("bang") // No tr |
49 | { | 49 | { |
50 | manarray = new QCanvasPixmapArray(); | 50 | manarray = new QCanvasPixmapArray(); |
51 | QString m0 = Resource::findPixmap("parashoot/man0001"); | 51 | QString m0 = Resource::findPixmap("parashoot/man0001"); |
@@ -62,7 +62,7 @@ Man::Man(QCanvas* canvas, int x, int y) : | |||
62 | first_time = FALSE; | 62 | first_time = FALSE; |
63 | QTime midnight(0, 0, 0); | 63 | QTime midnight(0, 0, 0); |
64 | srand(midnight.secsTo(QTime::currentTime()) ); | 64 | srand(midnight.secsTo(QTime::currentTime()) ); |
65 | } | 65 | } |
66 | int yfallspeed = 0; | 66 | int yfallspeed = 0; |
67 | yfallspeed = (rand() % 3) + 1; | 67 | yfallspeed = (rand() % 3) + 1; |
68 | setVelocity(0, yfallspeed); | 68 | setVelocity(0, yfallspeed); |
@@ -92,9 +92,16 @@ void Man::advance(int phase) | |||
92 | f++; | 92 | f++; |
93 | move(x(), canvas()->height()-26); | 93 | move(x(), canvas()->height()-26); |
94 | setVelocity(-2, 0); | 94 | setVelocity(-2, 0); |
95 | } | 95 | } else if (xVelocity() == -2) { |
96 | // | ||
97 | // There's been a resize event while this Man has | ||
98 | // been on the ground. Move the man back to the | ||
99 | // new ground location. This is not neat. | ||
100 | // | ||
101 | move(x(), canvas()->height()-26); | ||
102 | } | ||
96 | } | 103 | } |
97 | } | 104 | } |
98 | 105 | ||
99 | void Man::setInitialCoords() | 106 | void Man::setInitialCoords() |
100 | { | 107 | { |
@@ -110,7 +117,7 @@ void Man::setInitialCoords() | |||
110 | 117 | ||
111 | //check if man has reached the base | 118 | //check if man has reached the base |
112 | void Man::checkCollision() | 119 | void Man::checkCollision() |
113 | { | 120 | { |
114 | if ( (x() < 23) && (y() == canvas()->height()-26)) { | 121 | if ( (x() < 23) && (y() == canvas()->height()-26)) { |
115 | QCanvasItem* item; | 122 | QCanvasItem* item; |
116 | QCanvasItemList l=collisions(FALSE); | 123 | QCanvasItemList l=collisions(FALSE); |
@@ -123,6 +130,16 @@ void Man::checkCollision() | |||
123 | } | 130 | } |
124 | } | 131 | } |
125 | } | 132 | } |
133 | |||
134 | // | ||
135 | // resize events may cause Man objects to appear | ||
136 | // outside the screen. Get rid of them if this | ||
137 | // is the case. | ||
138 | // | ||
139 | if ((x() < 0) || (x() > canvas()->width())) { | ||
140 | delete this; | ||
141 | return; | ||
142 | } | ||
126 | } | 143 | } |
127 | 144 | ||
128 | void Man::start() | 145 | void Man::start() |