summaryrefslogtreecommitdiff
path: root/noncore/games/parashoot/man.cpp
Unidiff
Diffstat (limited to 'noncore/games/parashoot/man.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/parashoot/man.cpp39
1 files changed, 28 insertions, 11 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,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
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);
40 setAnimated(true); 40 setAnimated(true);
41 mancount++; 41 mancount++;
@@ -45,7 +45,7 @@ Man::Man(QCanvas* canvas) :
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");
@@ -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
99void Man::setInitialCoords() 106void 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
112void Man::checkCollision() 119void 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
128void Man::start() 145void Man::start()