summaryrefslogtreecommitdiff
path: root/noncore/games/parashoot/man.cpp
Unidiff
Diffstat (limited to 'noncore/games/parashoot/man.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/games/parashoot/man.cpp27
1 files changed, 22 insertions, 5 deletions
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,10 +1,10 @@
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**
@@ -19,21 +19,21 @@
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
29int mancount; 29int mancount;
30 30
31Man::Man(QCanvas* canvas) : 31Man::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);
@@ -42,13 +42,13 @@ Man::Man(QCanvas* canvas) :
42 dead = false; 42 dead = false;
43 start(); 43 start();
44} 44}
45 45
46Man::Man(QCanvas* canvas, int x, int y) : 46Man::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");
52 m0.replace(QString("0001"),"%1"); 52 m0.replace(QString("0001"),"%1");
53 manarray->readPixmaps(m0, 7); 53 manarray->readPixmaps(m0, 7);
54 setSequence(manarray); 54 setSequence(manarray);
@@ -89,12 +89,19 @@ void Man::advance(int phase)
89 } 89 }
90 if (y() > canvas()->height()-43) { 90 if (y() > canvas()->height()-43) {
91 setFrame(f%5); 91 setFrame(f%5);
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 } 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);
95 } 102 }
96 } 103 }
97} 104}
98 105
99void Man::setInitialCoords() 106void Man::setInitialCoords()
100{ 107{
@@ -120,12 +127,22 @@ void Man::checkCollision()
120 Base* base = (Base*) item; 127 Base* base = (Base*) item;
121 base->damageBase(); 128 base->damageBase();
122 start(); 129 start();
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
128void Man::start() 145void Man::start()
129{ 146{
130 setInitialCoords(); 147 setInitialCoords();
131 move(dx, dy); 148 move(dx, dy);