-rw-r--r-- | noncore/games/parashoot/.cvsignore | 3 | ||||
-rw-r--r-- | noncore/games/parashoot/Makefile.in | 203 | ||||
-rw-r--r-- | noncore/games/parashoot/base.cpp | 71 | ||||
-rw-r--r-- | noncore/games/parashoot/base.h | 38 | ||||
-rw-r--r-- | noncore/games/parashoot/bullet.cpp | 142 | ||||
-rw-r--r-- | noncore/games/parashoot/bullet.h | 51 | ||||
-rw-r--r-- | noncore/games/parashoot/cannon.cpp | 140 | ||||
-rw-r--r-- | noncore/games/parashoot/cannon.h | 58 | ||||
-rw-r--r-- | noncore/games/parashoot/codes.h | 25 | ||||
-rw-r--r-- | noncore/games/parashoot/helicopter.cpp | 114 | ||||
-rw-r--r-- | noncore/games/parashoot/helicopter.h | 45 | ||||
-rw-r--r-- | noncore/games/parashoot/interface.cpp | 247 | ||||
-rw-r--r-- | noncore/games/parashoot/interface.h | 79 | ||||
-rw-r--r-- | noncore/games/parashoot/main.cpp | 36 | ||||
-rw-r--r-- | noncore/games/parashoot/man.cpp | 174 | ||||
-rw-r--r-- | noncore/games/parashoot/man.h | 52 | ||||
-rw-r--r-- | noncore/games/parashoot/parashoot.pro | 11 | ||||
-rw-r--r-- | noncore/games/parashoot/qpe-parashoot.control | 9 |
18 files changed, 1498 insertions, 0 deletions
diff --git a/noncore/games/parashoot/.cvsignore b/noncore/games/parashoot/.cvsignore new file mode 100644 index 0000000..edfa921 --- a/dev/null +++ b/noncore/games/parashoot/.cvsignore | |||
@@ -0,0 +1,3 @@ | |||
1 | moc_* | ||
2 | *.moc | ||
3 | Makefile | ||
diff --git a/noncore/games/parashoot/Makefile.in b/noncore/games/parashoot/Makefile.in new file mode 100644 index 0000000..ff7397e --- a/dev/null +++ b/noncore/games/parashoot/Makefile.in | |||
@@ -0,0 +1,203 @@ | |||
1 | ############################################################################# | ||
2 | |||
3 | ####### Compiler, tools and options | ||
4 | |||
5 | CXX =$(SYSCONF_CXX) $(QT_CXX_MT) | ||
6 | CXXFLAGS=$(SYSCONF_CXXFLAGS_QT) $(SYSCONF_CXXFLAGS) | ||
7 | CC =$(SYSCONF_CC) $(QT_C_MT) | ||
8 | CFLAGS =$(SYSCONF_CFLAGS) | ||
9 | INCPATH =-I$(QPEDIR)/include | ||
10 | LFLAGS =$(SYSCONF_LFLAGS_QT) $(SYSCONF_RPATH_QT) $(SYSCONF_LFLAGS) $(QT_LFLAGS_MT) | ||
11 | LIBS =$(SUBLIBS) -lqpe $(SYSCONF_LIBS_QT) $(SYSCONF_LIBS) $(SYSCONF_LIBS_QTAPP) | ||
12 | MOC =$(SYSCONF_MOC) | ||
13 | UIC =$(SYSCONF_UIC) | ||
14 | |||
15 | ####### Target | ||
16 | |||
17 | DESTDIR = $(QPEDIR)/bin/ | ||
18 | VER_MAJ = 1 | ||
19 | VER_MIN = 0 | ||
20 | VER_PATCH = 0 | ||
21 | TARGET= parashoot | ||
22 | TARGET1 = lib$(TARGET).so.$(VER_MAJ) | ||
23 | |||
24 | ####### Files | ||
25 | |||
26 | HEADERS =interface.h \ | ||
27 | man.h \ | ||
28 | cannon.h \ | ||
29 | base.h \ | ||
30 | bullet.h \ | ||
31 | helicopter.h | ||
32 | SOURCES =main.cpp \ | ||
33 | interface.cpp \ | ||
34 | man.cpp \ | ||
35 | cannon.cpp \ | ||
36 | base.cpp \ | ||
37 | bullet.cpp \ | ||
38 | helicopter.cpp | ||
39 | OBJECTS =main.o \ | ||
40 | interface.o \ | ||
41 | man.o \ | ||
42 | cannon.o \ | ||
43 | base.o \ | ||
44 | bullet.o \ | ||
45 | helicopter.o | ||
46 | INTERFACES = | ||
47 | UICDECLS = | ||
48 | UICIMPLS = | ||
49 | SRCMOC =moc_interface.cpp \ | ||
50 | moc_cannon.cpp \ | ||
51 | moc_bullet.cpp | ||
52 | OBJMOC =moc_interface.o \ | ||
53 | moc_cannon.o \ | ||
54 | moc_bullet.o | ||
55 | |||
56 | |||
57 | ####### Implicit rules | ||
58 | |||
59 | .SUFFIXES: .cpp .cxx .cc .C .c | ||
60 | |||
61 | .cpp.o: | ||
62 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
63 | |||
64 | .cxx.o: | ||
65 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
66 | |||
67 | .cc.o: | ||
68 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
69 | |||
70 | .C.o: | ||
71 | $(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $< | ||
72 | |||
73 | .c.o: | ||
74 | $(CC) -c $(CFLAGS) $(INCPATH) -o $@ $< | ||
75 | |||
76 | ####### Build rules | ||
77 | |||
78 | |||
79 | all: $(DESTDIR)$(TARGET) | ||
80 | |||
81 | $(DESTDIR)$(TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS) | ||
82 | $(SYSCONF_LINK) $(LFLAGS) -o $(DESTDIR)$(TARGET) $(OBJECTS) $(OBJMOC) $(LIBS) | ||
83 | |||
84 | moc: $(SRCMOC) | ||
85 | |||
86 | tmake: | ||
87 | tmake parashoot.pro | ||
88 | |||
89 | clean: | ||
90 | -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS) | ||
91 | -rm -f *~ core | ||
92 | -rm -f allmoc.cpp | ||
93 | |||
94 | ####### Extension Modules | ||
95 | |||
96 | listpromodules: | ||
97 | @echo | ||
98 | |||
99 | listallmodules: | ||
100 | @echo | ||
101 | |||
102 | listaddonpromodules: | ||
103 | @echo | ||
104 | |||
105 | listaddonentmodules: | ||
106 | @echo | ||
107 | |||
108 | |||
109 | REQUIRES= | ||
110 | |||
111 | ####### Sub-libraries | ||
112 | |||
113 | |||
114 | ###### Combined headers | ||
115 | |||
116 | |||
117 | |||
118 | ####### Compile | ||
119 | |||
120 | main.o: main.cpp \ | ||
121 | interface.h \ | ||
122 | cannon.h \ | ||
123 | bullet.h \ | ||
124 | $(QPEDIR)/include/qpe/sound.h \ | ||
125 | base.h \ | ||
126 | helicopter.h \ | ||
127 | $(QPEDIR)/include/qpe/qpeapplication.h | ||
128 | |||
129 | interface.o: interface.cpp \ | ||
130 | interface.h \ | ||
131 | cannon.h \ | ||
132 | bullet.h \ | ||
133 | $(QPEDIR)/include/qpe/sound.h \ | ||
134 | base.h \ | ||
135 | helicopter.h \ | ||
136 | man.h \ | ||
137 | $(QPEDIR)/include/qpe/resource.h \ | ||
138 | $(QPEDIR)/include/qpe/qpetoolbar.h | ||
139 | |||
140 | man.o: man.cpp \ | ||
141 | codes.h \ | ||
142 | man.h \ | ||
143 | $(QPEDIR)/include/qpe/sound.h \ | ||
144 | base.h \ | ||
145 | $(QPEDIR)/include/qpe/resource.h | ||
146 | |||
147 | cannon.o: cannon.cpp \ | ||
148 | $(QPEDIR)/include/qpe/resource.h \ | ||
149 | codes.h \ | ||
150 | cannon.h \ | ||
151 | bullet.h \ | ||
152 | $(QPEDIR)/include/qpe/sound.h | ||
153 | |||
154 | base.o: base.cpp \ | ||
155 | codes.h \ | ||
156 | base.h \ | ||
157 | $(QPEDIR)/include/qpe/sound.h \ | ||
158 | man.h \ | ||
159 | $(QPEDIR)/include/qpe/resource.h | ||
160 | |||
161 | bullet.o: bullet.cpp \ | ||
162 | codes.h \ | ||
163 | bullet.h \ | ||
164 | $(QPEDIR)/include/qpe/sound.h \ | ||
165 | man.h \ | ||
166 | helicopter.h \ | ||
167 | $(QPEDIR)/include/qpe/resource.h \ | ||
168 | $(QPEDIR)/include/qpe/qmath.h | ||
169 | |||
170 | helicopter.o: helicopter.cpp \ | ||
171 | helicopter.h \ | ||
172 | $(QPEDIR)/include/qpe/sound.h \ | ||
173 | man.h \ | ||
174 | codes.h \ | ||
175 | $(QPEDIR)/include/qpe/resource.h | ||
176 | |||
177 | moc_interface.o: moc_interface.cpp \ | ||
178 | interface.h \ | ||
179 | cannon.h \ | ||
180 | bullet.h \ | ||
181 | $(QPEDIR)/include/qpe/sound.h \ | ||
182 | base.h \ | ||
183 | helicopter.h | ||
184 | |||
185 | moc_cannon.o: moc_cannon.cpp \ | ||
186 | cannon.h \ | ||
187 | bullet.h \ | ||
188 | $(QPEDIR)/include/qpe/sound.h | ||
189 | |||
190 | moc_bullet.o: moc_bullet.cpp \ | ||
191 | bullet.h \ | ||
192 | $(QPEDIR)/include/qpe/sound.h | ||
193 | |||
194 | moc_interface.cpp: interface.h | ||
195 | $(MOC) interface.h -o moc_interface.cpp | ||
196 | |||
197 | moc_cannon.cpp: cannon.h | ||
198 | $(MOC) cannon.h -o moc_cannon.cpp | ||
199 | |||
200 | moc_bullet.cpp: bullet.h | ||
201 | $(MOC) bullet.h -o moc_bullet.cpp | ||
202 | |||
203 | |||
diff --git a/noncore/games/parashoot/base.cpp b/noncore/games/parashoot/base.cpp new file mode 100644 index 0000000..c03802f --- a/dev/null +++ b/noncore/games/parashoot/base.cpp | |||
@@ -0,0 +1,71 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #include "codes.h" | ||
21 | #include "base.h" | ||
22 | #include "man.h" | ||
23 | |||
24 | #include <qpe/resource.h> | ||
25 | |||
26 | #include <qregexp.h> | ||
27 | |||
28 | int damage; | ||
29 | |||
30 | Base::Base(QCanvas* canvas) : | ||
31 | QCanvasSprite(0, canvas), | ||
32 | kaboom("landmine"), | ||
33 | ohdear("crmble01") | ||
34 | { | ||
35 | basearray = new QCanvasPixmapArray(); | ||
36 | QString b0 = Resource::findPixmap("parashoot/b0001"); | ||
37 | b0.replace(QRegExp("0001"),"%1"); | ||
38 | basearray->readPixmaps(b0, 4); | ||
39 | setSequence(basearray); | ||
40 | setFrame(0); | ||
41 | move(2, canvas->height()-50); | ||
42 | setZ(10); | ||
43 | show(); | ||
44 | damage = 0; | ||
45 | } | ||
46 | |||
47 | void Base::damageBase() | ||
48 | { | ||
49 | damage++; | ||
50 | |||
51 | switch(damage) { | ||
52 | case 1: setFrame(1); ohdear.play(); break; | ||
53 | case 2: setFrame(2); ohdear.play(); break; | ||
54 | case 3: setFrame(3); kaboom.play(); break; | ||
55 | } | ||
56 | show(); | ||
57 | } | ||
58 | |||
59 | bool Base::baseDestroyed() | ||
60 | { | ||
61 | return (damage >= 3); | ||
62 | } | ||
63 | |||
64 | Base::~Base() | ||
65 | { | ||
66 | } | ||
67 | |||
68 | int Base::rtti() const | ||
69 | { | ||
70 | return base_rtti; | ||
71 | } | ||
diff --git a/noncore/games/parashoot/base.h b/noncore/games/parashoot/base.h new file mode 100644 index 0000000..ee7f166 --- a/dev/null +++ b/noncore/games/parashoot/base.h | |||
@@ -0,0 +1,38 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include <qpe/sound.h> | ||
22 | |||
23 | #include <qcanvas.h> | ||
24 | |||
25 | class Base : public QCanvasSprite | ||
26 | { | ||
27 | |||
28 | public: | ||
29 | Base(QCanvas*); | ||
30 | ~Base(); | ||
31 | void damageBase(); | ||
32 | int rtti() const; | ||
33 | static bool baseDestroyed(); | ||
34 | |||
35 | private: | ||
36 | QCanvasPixmapArray* basearray; | ||
37 | Sound kaboom, ohdear; | ||
38 | }; | ||
diff --git a/noncore/games/parashoot/bullet.cpp b/noncore/games/parashoot/bullet.cpp new file mode 100644 index 0000000..584f564 --- a/dev/null +++ b/noncore/games/parashoot/bullet.cpp | |||
@@ -0,0 +1,142 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include "codes.h" | ||
22 | #include "bullet.h" | ||
23 | #include "man.h" | ||
24 | #include "helicopter.h" | ||
25 | |||
26 | #include <qpe/resource.h> | ||
27 | #include <qpe/qmath.h> | ||
28 | |||
29 | |||
30 | int limit; | ||
31 | int shotcount; | ||
32 | int nobullets; | ||
33 | |||
34 | Bullet::Bullet(QCanvas* canvas, double angle, int cannonx, int cannony) : | ||
35 | QCanvasSprite(0, canvas), | ||
36 | bang("collide01") | ||
37 | { | ||
38 | QCanvasPixmapArray* bulletarray = new QCanvasPixmapArray(Resource::findPixmap("parashoot/bullet")); | ||
39 | setSequence(bulletarray); | ||
40 | if (nobullets < limit) { | ||
41 | nobullets++; | ||
42 | move(cannonx, cannony); | ||
43 | dy = 0; | ||
44 | dx = 0; | ||
45 | show(); | ||
46 | setXY(angle); | ||
47 | setVelocity(-dx, -dy); | ||
48 | bang.play(); | ||
49 | } else | ||
50 | return; | ||
51 | } | ||
52 | |||
53 | void Bullet::setXY(double angle) | ||
54 | { | ||
55 | double ang = angle; | ||
56 | if ( (y() < 0) || (x() < 0) || (y() > canvas()->height()) || | ||
57 | (x() > canvas()->width()) ) | ||
58 | delete this; | ||
59 | else { | ||
60 | double radians = 0; | ||
61 | radians = ang * 3.14159265/180; | ||
62 | dx = (qCos(radians)) *7; | ||
63 | dy = (qSin(radians)) *7; | ||
64 | } | ||
65 | } | ||
66 | |||
67 | void Bullet::setLimit(int amount) | ||
68 | { | ||
69 | limit = amount; | ||
70 | } | ||
71 | |||
72 | void Bullet::setNobullets(int amount) | ||
73 | { | ||
74 | nobullets = amount; | ||
75 | } | ||
76 | |||
77 | void Bullet::checkCollision() | ||
78 | { | ||
79 | QCanvasItem* item; | ||
80 | QCanvasItemList l=collisions(FALSE); | ||
81 | for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) { | ||
82 | item = *it; | ||
83 | if ( (item->rtti()== 1500) && (item->collidesWith(this)) ) { | ||
84 | Man* deadman = (Man*)item; | ||
85 | if (deadman->frame() != 5) return; | ||
86 | deadman->done(); | ||
87 | emit score(10); | ||
88 | setShotCount(shotcount+1); | ||
89 | setAnimated(false); | ||
90 | nobullets--; | ||
91 | delete this; | ||
92 | return; | ||
93 | } | ||
94 | else if ( (item->rtti()==1900) && (item->collidesWith(this)) ) { | ||
95 | Helicopter* deadchopper = (Helicopter*) item; | ||
96 | deadchopper->done(); | ||
97 | emit score(50); | ||
98 | setAnimated(false); | ||
99 | nobullets--; | ||
100 | delete this; | ||
101 | return; | ||
102 | } | ||
103 | } | ||
104 | //check shot is not out of bounds | ||
105 | if ( (y() < 0) || (x() < 0) || | ||
106 | (y() > canvas()->height()) || | ||
107 | ( x() > canvas()->width())) { | ||
108 | setAnimated(false); | ||
109 | nobullets--; | ||
110 | delete this; | ||
111 | return; | ||
112 | } | ||
113 | } | ||
114 | |||
115 | void Bullet::advance(int phase) | ||
116 | { | ||
117 | QCanvasSprite::advance(phase); | ||
118 | |||
119 | if (phase == 0) | ||
120 | checkCollision(); | ||
121 | |||
122 | } | ||
123 | |||
124 | int Bullet::getShotCount() | ||
125 | { | ||
126 | return shotcount; | ||
127 | } | ||
128 | |||
129 | void Bullet::setShotCount(int amount) | ||
130 | { | ||
131 | shotcount = amount; | ||
132 | } | ||
133 | |||
134 | Bullet::~Bullet() | ||
135 | { | ||
136 | |||
137 | } | ||
138 | |||
139 | int Bullet::rtti() const | ||
140 | { | ||
141 | return bullet_rtti; | ||
142 | } | ||
diff --git a/noncore/games/parashoot/bullet.h b/noncore/games/parashoot/bullet.h new file mode 100644 index 0000000..7d15899 --- a/dev/null +++ b/noncore/games/parashoot/bullet.h | |||
@@ -0,0 +1,51 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include <qpe/sound.h> | ||
22 | |||
23 | #include <qtimer.h> | ||
24 | #include <qcanvas.h> | ||
25 | |||
26 | #include <math.h> | ||
27 | |||
28 | class Bullet : public QObject, public QCanvasSprite | ||
29 | { | ||
30 | Q_OBJECT | ||
31 | public: | ||
32 | Bullet(QCanvas*, double angle, int cannonx, int cannony); | ||
33 | ~Bullet(); | ||
34 | void setXY(double angle); | ||
35 | void checkCollision(); | ||
36 | void advance(int phase); | ||
37 | int rtti() const; | ||
38 | static int getShotCount(); | ||
39 | static void setShotCount(int amount); | ||
40 | static void setLimit(int amount); | ||
41 | static void setNobullets(int amount); | ||
42 | |||
43 | signals: | ||
44 | void score(int); | ||
45 | |||
46 | private: | ||
47 | double dx; | ||
48 | double dy; | ||
49 | int damage; | ||
50 | Sound bang; | ||
51 | }; | ||
diff --git a/noncore/games/parashoot/cannon.cpp b/noncore/games/parashoot/cannon.cpp new file mode 100644 index 0000000..3c0a5fe --- a/dev/null +++ b/noncore/games/parashoot/cannon.cpp | |||
@@ -0,0 +1,140 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include <qpe/resource.h> | ||
22 | |||
23 | #include <qregexp.h> | ||
24 | |||
25 | #include "codes.h" | ||
26 | #include "cannon.h" | ||
27 | |||
28 | Cannon::Cannon(QCanvas* canvas) : | ||
29 | QCanvasSprite(0, canvas) | ||
30 | { | ||
31 | shotsfired=0; | ||
32 | index = 8; | ||
33 | cannonx = 0; | ||
34 | cannony = 0; | ||
35 | cannonarray = new QCanvasPixmapArray(); | ||
36 | QString c0 = Resource::findPixmap("parashoot/can0001"); | ||
37 | c0.replace(QRegExp("0001"),"%1"); | ||
38 | cannonarray->readPixmaps(c0,17); | ||
39 | setSequence(cannonarray); | ||
40 | setFrame(index); | ||
41 | move(canvas->width()/2-20, canvas->height()-32); | ||
42 | // co ords for barrel of cannon when upright | ||
43 | barrelypos = canvas->height()-32; | ||
44 | barrelxpos = canvas->width()/2; | ||
45 | movedir = NoDir; | ||
46 | moveDelay = 0; | ||
47 | setAnimated(TRUE); | ||
48 | show(); | ||
49 | } | ||
50 | |||
51 | void Cannon::advance(int stage) | ||
52 | { | ||
53 | if ( stage == 1 && moveDelay-- == 0 ) { | ||
54 | if (movedir == Left) { | ||
55 | if (index > 0) { | ||
56 | setFrame(index-1); | ||
57 | index--; | ||
58 | } | ||
59 | } | ||
60 | if (movedir == Right) { | ||
61 | if (index < 16) { | ||
62 | setFrame(index+1); | ||
63 | index++; | ||
64 | } | ||
65 | } | ||
66 | moveDelay = 0; | ||
67 | } | ||
68 | } | ||
69 | |||
70 | void Cannon::pointCannon(Direction dir) | ||
71 | { | ||
72 | movedir = dir; | ||
73 | moveDelay = 0; | ||
74 | advance(1); | ||
75 | moveDelay = 1; | ||
76 | } | ||
77 | |||
78 | void Cannon::setCoords() | ||
79 | { | ||
80 | switch(index) { | ||
81 | case 0: cannonx = barrelxpos-29; cannony = barrelypos-8; break; | ||
82 | case 1: cannonx = barrelxpos-27; cannony = barrelypos-8; break; | ||
83 | case 2: cannonx = barrelxpos-25; cannony = barrelypos-6; break; | ||
84 | case 3: cannonx = barrelxpos-23; cannony = barrelypos-4; break; | ||
85 | case 4: cannonx = barrelxpos-21; cannony = barrelypos-2; break; | ||
86 | case 5: cannonx = barrelxpos-19; cannony = barrelypos; break; | ||
87 | case 6: cannonx = barrelxpos-15; cannony = barrelypos; break; | ||
88 | case 7: cannonx = barrelxpos-10; cannony = barrelypos; break; | ||
89 | case 8: cannonx = barrelxpos; cannony = barrelypos; break; | ||
90 | case 9: cannonx = barrelxpos+2; cannony = barrelypos; break; | ||
91 | case 10: cannonx = barrelxpos+6; cannony = barrelypos; break; | ||
92 | case 11: cannonx = barrelxpos+8; cannony = barrelypos; break; | ||
93 | case 12: cannonx = barrelxpos+12; cannony = barrelypos-2; break; | ||
94 | case 13: cannonx = barrelxpos+18; cannony = barrelypos-4; break; | ||
95 | case 14: cannonx = barrelxpos+22; cannony = barrelypos-6; break; | ||
96 | case 15: cannonx = barrelxpos+26; cannony = barrelypos-8; break; | ||
97 | case 16: cannonx = barrelxpos+28; cannony = barrelypos-8; break; | ||
98 | } | ||
99 | } | ||
100 | |||
101 | double Cannon::shootAngle() | ||
102 | { | ||
103 | switch(index) { | ||
104 | case 0: return 30.0; | ||
105 | case 1: return 37.5; | ||
106 | case 2: return 45.0; | ||
107 | case 3: return 52.5; | ||
108 | case 4: return 60.0; | ||
109 | case 5: return 67.5; | ||
110 | case 6: return 75.0; | ||
111 | case 7: return 82.5; | ||
112 | case 8: return 90.0; | ||
113 | case 9: return 97.5; | ||
114 | case 10: return 105.0; | ||
115 | case 11: return 112.5; | ||
116 | case 12: return 120.0; | ||
117 | case 13: return 127.5; | ||
118 | case 14: return 135.0; | ||
119 | case 15: return 142.5; | ||
120 | case 16: return 150.0; | ||
121 | } | ||
122 | return 0; | ||
123 | } | ||
124 | |||
125 | void Cannon::shoot() | ||
126 | { | ||
127 | setCoords(); | ||
128 | Bullet* bullet = new Bullet(canvas(), shootAngle(), cannonx, cannony); | ||
129 | connect(bullet, SIGNAL(score(int)), this, SIGNAL(score(int))); | ||
130 | shotsfired++; | ||
131 | } | ||
132 | |||
133 | Cannon::~Cannon() | ||
134 | { | ||
135 | } | ||
136 | |||
137 | int Cannon::rtti() const | ||
138 | { | ||
139 | return cannon_rtti; | ||
140 | } | ||
diff --git a/noncore/games/parashoot/cannon.h b/noncore/games/parashoot/cannon.h new file mode 100644 index 0000000..44d0c65 --- a/dev/null +++ b/noncore/games/parashoot/cannon.h | |||
@@ -0,0 +1,58 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #include <qcanvas.h> | ||
21 | |||
22 | #include "bullet.h" | ||
23 | |||
24 | class Cannon : public QObject, public QCanvasSprite | ||
25 | { | ||
26 | Q_OBJECT | ||
27 | |||
28 | public: | ||
29 | Cannon(QCanvas*); //create cannon | ||
30 | ~Cannon(); //destroy cannon | ||
31 | |||
32 | enum Direction{ Left, Right, NoDir }; | ||
33 | |||
34 | void pointCannon(Direction dir); | ||
35 | void setCoords(); | ||
36 | double shootAngle(); | ||
37 | void shoot(); | ||
38 | int rtti() const; | ||
39 | |||
40 | int shotsFired() { return shotsfired; }; | ||
41 | |||
42 | protected: | ||
43 | void advance(int stage); | ||
44 | |||
45 | signals: | ||
46 | void score(int); | ||
47 | |||
48 | private: | ||
49 | QCanvasPixmapArray* cannonarray; | ||
50 | int index; | ||
51 | int cannonx; | ||
52 | int cannony; | ||
53 | int barrelxpos; | ||
54 | int barrelypos; | ||
55 | int moveDelay; | ||
56 | Direction movedir; | ||
57 | int shotsfired; | ||
58 | }; | ||
diff --git a/noncore/games/parashoot/codes.h b/noncore/games/parashoot/codes.h new file mode 100644 index 0000000..68acb3f --- a/dev/null +++ b/noncore/games/parashoot/codes.h | |||
@@ -0,0 +1,25 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | const int man_rtti = 1500; | ||
22 | const int bullet_rtti = 1600; | ||
23 | const int cannon_rtti = 1700; | ||
24 | const int base_rtti = 1800; | ||
25 | const int helicopter_rtti = 1900; | ||
diff --git a/noncore/games/parashoot/helicopter.cpp b/noncore/games/parashoot/helicopter.cpp new file mode 100644 index 0000000..0923124 --- a/dev/null +++ b/noncore/games/parashoot/helicopter.cpp | |||
@@ -0,0 +1,114 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include "helicopter.h" | ||
22 | #include "man.h" | ||
23 | #include "codes.h" | ||
24 | |||
25 | #include <qpe/resource.h> | ||
26 | |||
27 | #include <qregexp.h> | ||
28 | |||
29 | static QList<Helicopter> all; | ||
30 | |||
31 | Helicopter::Helicopter(QCanvas* canvas) : | ||
32 | QCanvasSprite(0, canvas), | ||
33 | chikachika("aland01") | ||
34 | { | ||
35 | all.append(this); | ||
36 | hits = 0; | ||
37 | QCanvasPixmapArray* helicopterarray = new QCanvasPixmapArray(); | ||
38 | QString h0 = Resource::findPixmap("parashoot/helicopter0001"); | ||
39 | h0.replace(QRegExp("0001"),"%1"); | ||
40 | helicopterarray->readPixmaps(h0,3 ); | ||
41 | setSequence(helicopterarray); | ||
42 | setAnimated(true); | ||
43 | move(canvas->width(), 5); | ||
44 | setVelocity(-2, 0); | ||
45 | chikachika.playLoop(); | ||
46 | show(); | ||
47 | } | ||
48 | |||
49 | Helicopter::~Helicopter() | ||
50 | { | ||
51 | all.remove(this); | ||
52 | } | ||
53 | |||
54 | int fr = 0; | ||
55 | |||
56 | void Helicopter::advance(int phase) | ||
57 | { | ||
58 | QCanvasSprite::advance(phase); | ||
59 | if (phase == 0) { | ||
60 | setFrame(fr%3); | ||
61 | fr++; | ||
62 | checkCollision(); | ||
63 | } | ||
64 | } | ||
65 | |||
66 | void Helicopter::checkCollision() | ||
67 | { | ||
68 | if (x() == 6) { | ||
69 | setAnimated(false); //setVelocity(0, 0); | ||
70 | dropman(); | ||
71 | } | ||
72 | if (x() < 0) | ||
73 | done(); | ||
74 | } | ||
75 | |||
76 | void Helicopter::dropman() | ||
77 | { | ||
78 | (void)new Man(canvas(), 15, 25); | ||
79 | (void)new Man(canvas(), 35, 25); | ||
80 | takeOff(); | ||
81 | } | ||
82 | |||
83 | void Helicopter::done() | ||
84 | { | ||
85 | hits++; | ||
86 | if (hits >= 2) { | ||
87 | setAnimated(false); | ||
88 | delete this; | ||
89 | } | ||
90 | } | ||
91 | |||
92 | void Helicopter::takeOff() | ||
93 | { | ||
94 | setVelocity(-1, 0); | ||
95 | } | ||
96 | |||
97 | int Helicopter::rtti() const | ||
98 | { | ||
99 | return helicopter_rtti; | ||
100 | } | ||
101 | |||
102 | void Helicopter::silenceAll() | ||
103 | { | ||
104 | for (Helicopter* h = all.first(); h; h = all.next()) | ||
105 | h->chikachika.stop(); | ||
106 | } | ||
107 | |||
108 | void Helicopter::deleteAll() | ||
109 | { | ||
110 | Helicopter* h; | ||
111 | while ((h = all.first())) | ||
112 | delete h; | ||
113 | } | ||
114 | |||
diff --git a/noncore/games/parashoot/helicopter.h b/noncore/games/parashoot/helicopter.h new file mode 100644 index 0000000..5cb92de --- a/dev/null +++ b/noncore/games/parashoot/helicopter.h | |||
@@ -0,0 +1,45 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include <qpe/sound.h> | ||
22 | |||
23 | #include <qcanvas.h> | ||
24 | |||
25 | class Helicopter : public QCanvasSprite | ||
26 | { | ||
27 | |||
28 | public: | ||
29 | Helicopter(QCanvas*); | ||
30 | ~Helicopter(); | ||
31 | void advance(int phase); | ||
32 | void checkCollision(); | ||
33 | void dropman(); | ||
34 | void takeOff(); | ||
35 | void done(); | ||
36 | |||
37 | static void silenceAll(); | ||
38 | static void deleteAll(); | ||
39 | |||
40 | int rtti() const; | ||
41 | |||
42 | private: | ||
43 | int hits; | ||
44 | Sound chikachika; | ||
45 | }; | ||
diff --git a/noncore/games/parashoot/interface.cpp b/noncore/games/parashoot/interface.cpp new file mode 100644 index 0000000..84e5e60 --- a/dev/null +++ b/noncore/games/parashoot/interface.cpp | |||
@@ -0,0 +1,247 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include "interface.h" | ||
22 | #include "man.h" | ||
23 | |||
24 | #include <qpe/resource.h> | ||
25 | |||
26 | #include <qlabel.h> | ||
27 | #include <qmessagebox.h> | ||
28 | #include <qapplication.h> | ||
29 | #include <qstyle.h> | ||
30 | #include <qpe/qpetoolbar.h> | ||
31 | #include <qtoolbutton.h> | ||
32 | |||
33 | ParaShoot::ParaShoot(QWidget* parent, const char* name, WFlags f) : | ||
34 | QMainWindow(parent,name,f), | ||
35 | canvas(232, 258), | ||
36 | fanfare("level_up"), | ||
37 | score(0) | ||
38 | { | ||
39 | canvas.setAdvancePeriod(80); | ||
40 | QPixmap bg = Resource::loadPixmap("parashoot/sky"); | ||
41 | canvas.setBackgroundPixmap(bg); | ||
42 | |||
43 | pb = new QCanvasView(&canvas, this); | ||
44 | pb->setFocus(); | ||
45 | |||
46 | setToolBarsMovable( FALSE ); | ||
47 | |||
48 | QPEToolBar* toolbar = new QPEToolBar(this); | ||
49 | toolbar->setHorizontalStretchable( TRUE ); | ||
50 | |||
51 | setCaption( tr("ParaShoot") ); | ||
52 | QPixmap newicon = Resource::loadPixmap("parashoot/manicon"); | ||
53 | setIcon(newicon); | ||
54 | new QToolButton(newicon, tr("New Game"), 0, | ||
55 | this, SLOT(newGame()), toolbar, "New Game"); | ||
56 | |||
57 | levelscore = new QLabel(toolbar); | ||
58 | levelscore->setBackgroundMode( PaletteButton ); | ||
59 | levelscore->setAlignment( AlignRight | AlignVCenter | ExpandTabs ); | ||
60 | toolbar->setStretchableWidget( levelscore ); | ||
61 | showScore(0,0); | ||
62 | |||
63 | setCentralWidget(pb); | ||
64 | |||
65 | autoDropTimer = new QTimer(this); | ||
66 | connect (autoDropTimer, SIGNAL(timeout()), this, SLOT(play()) ); | ||
67 | |||
68 | pauseTimer = new QTimer(this); | ||
69 | connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) ); | ||
70 | |||
71 | setFocusPolicy(StrongFocus); | ||
72 | |||
73 | newGame(); | ||
74 | } | ||
75 | |||
76 | |||
77 | void ParaShoot::resizeEvent(QResizeEvent *) | ||
78 | { | ||
79 | QSize s = centralWidget()->size(); | ||
80 | int fw = style().defaultFrameWidth(); | ||
81 | canvas.resize( s.width() - fw - 2, s.height() - fw - 2); | ||
82 | } | ||
83 | |||
84 | |||
85 | void ParaShoot::showScore( int score, int level ) | ||
86 | { | ||
87 | levelscore->setText(tr(" Level: %1 Score: %2 ").arg(score).arg(level) ); | ||
88 | } | ||
89 | |||
90 | |||
91 | void ParaShoot::newGame() | ||
92 | { | ||
93 | clear(); | ||
94 | if (pauseTimer->isActive()) | ||
95 | pauseTimer->stop(); | ||
96 | clear(); | ||
97 | Man::setManCount(0); | ||
98 | score = 0; | ||
99 | Bullet::setShotCount(0); | ||
100 | Bullet::setNobullets(0); | ||
101 | nomen = 2; | ||
102 | Bullet::setLimit(nomen); | ||
103 | level = 0; | ||
104 | updatespeed = 80; | ||
105 | showScore(0,0); | ||
106 | gamestopped = false; | ||
107 | Helicopter::deleteAll(); | ||
108 | waitover = true; | ||
109 | base = new Base(&canvas); | ||
110 | cannon = new Cannon(&canvas); | ||
111 | connect( cannon, SIGNAL(score(int)), this, SLOT(increaseScore(int))); | ||
112 | autoDropTimer->start(100); | ||
113 | } | ||
114 | |||
115 | |||
116 | void ParaShoot::clear() | ||
117 | { | ||
118 | autoDropTimer->stop(); | ||
119 | // QCanvasItem* item; | ||
120 | QCanvasItemList l = canvas.allItems(); | ||
121 | for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) { | ||
122 | delete *it; | ||
123 | } | ||
124 | } | ||
125 | |||
126 | void ParaShoot::gameOver() | ||
127 | { | ||
128 | QCanvasItem* item; | ||
129 | QCanvasItemList l = canvas.allItems(); | ||
130 | for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) { | ||
131 | item = *it; | ||
132 | if ((item->rtti()==1500) || (item->rtti()==1600) || item->rtti()==1900) | ||
133 | item->setAnimated(false); | ||
134 | } | ||
135 | autoDropTimer->stop(); | ||
136 | Helicopter::silenceAll(); | ||
137 | |||
138 | int shots = Bullet::getShotCount(); | ||
139 | |||
140 | int shotsFired = cannon->shotsFired(); | ||
141 | if ( shotsFired == 0 ) | ||
142 | shotsFired = 1; | ||
143 | QCanvasText* gameover = new QCanvasText( | ||
144 | tr( " GAME OVER!\n" | ||
145 | " Your Score: %1\n" | ||
146 | " Parachuters Killed: %2\n" | ||
147 | " Accuracy: %3% " ).arg(score).arg(shots).arg(shots * 100 / shotsFired ), | ||
148 | &canvas); | ||
149 | gameover->setColor(red); | ||
150 | gameover->setFont( QFont("times", 18, QFont::Bold) ); | ||
151 | gameover->move(canvas.width()/2 -110, canvas.height()/2 -50); | ||
152 | gameover->setZ(500); | ||
153 | gameover->show(); | ||
154 | gamestopped = true; | ||
155 | waitover = false; | ||
156 | pauseTimer->start(3000); | ||
157 | } | ||
158 | |||
159 | void ParaShoot::wait() | ||
160 | { | ||
161 | waitover = true; | ||
162 | pauseTimer->stop(); | ||
163 | } | ||
164 | |||
165 | void ParaShoot::play() | ||
166 | { | ||
167 | if (Man::getManCount() < nomen ) { | ||
168 | new Man(&canvas); | ||
169 | } | ||
170 | if (Base::baseDestroyed()) { | ||
171 | gameOver(); | ||
172 | return; | ||
173 | } | ||
174 | } | ||
175 | |||
176 | void ParaShoot::increaseScore(int x) | ||
177 | { | ||
178 | score += x; | ||
179 | if ( score / 150 != (score-x) / 150 ) | ||
180 | levelUp(); | ||
181 | showScore(level,score); | ||
182 | } | ||
183 | |||
184 | void ParaShoot::levelUp() | ||
185 | { | ||
186 | level++; | ||
187 | int stage = level % 3; | ||
188 | switch(stage) { | ||
189 | case 0: | ||
190 | nomen++; | ||
191 | Bullet::setLimit(nomen); | ||
192 | fanfare.play(); | ||
193 | break; | ||
194 | case 1: | ||
195 | new Helicopter(&canvas); | ||
196 | break; | ||
197 | case 2: | ||
198 | moveFaster(); | ||
199 | fanfare.play(); | ||
200 | break; | ||
201 | default: return; | ||
202 | } | ||
203 | } | ||
204 | |||
205 | void ParaShoot::moveFaster() | ||
206 | { | ||
207 | if (updatespeed > 50) | ||
208 | updatespeed = updatespeed-5; | ||
209 | else | ||
210 | updatespeed = updatespeed-3; | ||
211 | canvas.setAdvancePeriod(updatespeed); | ||
212 | } | ||
213 | |||
214 | void ParaShoot::keyPressEvent(QKeyEvent* event) | ||
215 | { | ||
216 | if (gamestopped) { | ||
217 | if (waitover) | ||
218 | newGame(); | ||
219 | else | ||
220 | return; | ||
221 | } else { | ||
222 | switch(event->key()) { | ||
223 | case Key_Up: | ||
224 | case Key_F1: | ||
225 | case Key_F9: | ||
226 | case Key_Space: | ||
227 | cannon->shoot(); | ||
228 | break; | ||
229 | case Key_Left: | ||
230 | cannon->pointCannon(Cannon::Left); | ||
231 | lastcannonkey=Key_Left; | ||
232 | break; | ||
233 | case Key_Right: | ||
234 | cannon->pointCannon(Cannon::Right); | ||
235 | lastcannonkey=Key_Right; | ||
236 | break; | ||
237 | default: | ||
238 | return; | ||
239 | } | ||
240 | } | ||
241 | } | ||
242 | |||
243 | void ParaShoot::keyReleaseEvent(QKeyEvent* event) | ||
244 | { | ||
245 | if ( lastcannonkey == event->key() ) | ||
246 | cannon->pointCannon(Cannon::NoDir); | ||
247 | } | ||
diff --git a/noncore/games/parashoot/interface.h b/noncore/games/parashoot/interface.h new file mode 100644 index 0000000..3f36d0b --- a/dev/null +++ b/noncore/games/parashoot/interface.h | |||
@@ -0,0 +1,79 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include "cannon.h" | ||
22 | #include "base.h" | ||
23 | #include "helicopter.h" | ||
24 | |||
25 | #include <qpe/sound.h> | ||
26 | |||
27 | #include <qmainwindow.h> | ||
28 | #include <qtimer.h> | ||
29 | #include <qlabel.h> | ||
30 | |||
31 | class QCanvas; | ||
32 | class Helicopter; | ||
33 | |||
34 | //enum Direction{ | ||
35 | // left, right, up, down }; | ||
36 | |||
37 | class ParaShoot : public QMainWindow { | ||
38 | Q_OBJECT | ||
39 | |||
40 | public: | ||
41 | ParaShoot(QWidget* parent=0, const char* name=0, WFlags f=0); | ||
42 | |||
43 | void clear(); | ||
44 | void gameOver(); | ||
45 | int mancount; | ||
46 | void levelUp(); | ||
47 | void moveFaster(); | ||
48 | |||
49 | protected: | ||
50 | virtual void keyPressEvent(QKeyEvent*); | ||
51 | virtual void keyReleaseEvent(QKeyEvent*); | ||
52 | virtual void resizeEvent(QResizeEvent *e); | ||
53 | |||
54 | private slots: | ||
55 | void increaseScore(int); | ||
56 | void newGame(); | ||
57 | void play(); | ||
58 | void wait(); | ||
59 | |||
60 | private: | ||
61 | void showScore( int score, int level ); | ||
62 | QCanvasView* pb; | ||
63 | QCanvas canvas; | ||
64 | Cannon* cannon; | ||
65 | Base* base; | ||
66 | QCanvasText* gameover; | ||
67 | QLabel* levelscore; | ||
68 | int nomen; | ||
69 | int level; | ||
70 | int oldscore; | ||
71 | int updatespeed; | ||
72 | QTimer* autoDropTimer; | ||
73 | QTimer* pauseTimer; | ||
74 | bool gamestopped; | ||
75 | bool waitover; | ||
76 | Sound fanfare; | ||
77 | int score; | ||
78 | int lastcannonkey; | ||
79 | }; | ||
diff --git a/noncore/games/parashoot/main.cpp b/noncore/games/parashoot/main.cpp new file mode 100644 index 0000000..60eea18 --- a/dev/null +++ b/noncore/games/parashoot/main.cpp | |||
@@ -0,0 +1,36 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include "interface.h" | ||
22 | |||
23 | #include <qpe/qpeapplication.h> | ||
24 | |||
25 | int main(int argc, char **argv) | ||
26 | { | ||
27 | QPEApplication app(argc,argv); | ||
28 | |||
29 | QPEApplication::grabKeyboard(); | ||
30 | |||
31 | ParaShoot m; | ||
32 | QPEApplication::setInputMethodHint( &m, QPEApplication::AlwaysOff ); | ||
33 | app.showMainWidget(&m); | ||
34 | |||
35 | return app.exec(); | ||
36 | } | ||
diff --git a/noncore/games/parashoot/man.cpp b/noncore/games/parashoot/man.cpp new file mode 100644 index 0000000..8435572 --- a/dev/null +++ b/noncore/games/parashoot/man.cpp | |||
@@ -0,0 +1,174 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include "codes.h" | ||
22 | #include "man.h" | ||
23 | #include "base.h" | ||
24 | |||
25 | #include <qpe/resource.h> | ||
26 | |||
27 | #include <qregexp.h> | ||
28 | |||
29 | int mancount; | ||
30 | |||
31 | Man::Man(QCanvas* canvas) : | ||
32 | QCanvasSprite(0, canvas), | ||
33 | splat("lose") | ||
34 | { | ||
35 | manarray = new QCanvasPixmapArray(); | ||
36 | QString m0 = Resource::findPixmap("parashoot/man0001"); | ||
37 | m0.replace(QRegExp("0001"),"%1"); | ||
38 | manarray->readPixmaps(m0, 7); | ||
39 | setSequence(manarray); | ||
40 | setAnimated(true); | ||
41 | mancount++; | ||
42 | dead = false; | ||
43 | start(); | ||
44 | } | ||
45 | |||
46 | Man::Man(QCanvas* canvas, int x, int y) : | ||
47 | QCanvasSprite(0, canvas), | ||
48 | splat("bang") | ||
49 | { | ||
50 | manarray = new QCanvasPixmapArray(); | ||
51 | QString m0 = Resource::findPixmap("parashoot/man0001"); | ||
52 | m0.replace(QString("0001"),"%1"); | ||
53 | manarray->readPixmaps(m0, 7); | ||
54 | setSequence(manarray); | ||
55 | move(x, y); | ||
56 | setFrame(5); | ||
57 | setZ(300); | ||
58 | show(); | ||
59 | |||
60 | static bool first_time = TRUE; | ||
61 | if (first_time) { | ||
62 | first_time = FALSE; | ||
63 | QTime midnight(0, 0, 0); | ||
64 | srand(midnight.secsTo(QTime::currentTime()) ); | ||
65 | } | ||
66 | int yfallspeed = 0; | ||
67 | yfallspeed = (rand() % 3) + 1; | ||
68 | setVelocity(0, yfallspeed); | ||
69 | |||
70 | mancount++; | ||
71 | dead = false; | ||
72 | } | ||
73 | int f = 0; | ||
74 | |||
75 | void Man::advance(int phase) | ||
76 | { | ||
77 | QCanvasSprite::advance(phase); | ||
78 | if (phase == 0) { | ||
79 | checkCollision(); | ||
80 | if (dead) { | ||
81 | if (count < 10) { | ||
82 | setFrame(6); | ||
83 | setVelocity(0,0); | ||
84 | count++; | ||
85 | } else { | ||
86 | delete this; | ||
87 | return; | ||
88 | } | ||
89 | } | ||
90 | if (y() > canvas()->height()-43) { | ||
91 | setFrame(f%5); | ||
92 | f++; | ||
93 | move(x(), canvas()->height()-26); | ||
94 | setVelocity(-2, 0); | ||
95 | } | ||
96 | } | ||
97 | } | ||
98 | |||
99 | void Man::setInitialCoords() | ||
100 | { | ||
101 | static bool first_time = TRUE; | ||
102 | if (first_time) { | ||
103 | first_time = FALSE; | ||
104 | QTime midnight(0, 0, 0); | ||
105 | srand(midnight.secsTo(QTime::currentTime()) ); | ||
106 | } | ||
107 | dx = rand() % (canvas()->width()-16); | ||
108 | dy = -43; //height of a man off the screen | ||
109 | } | ||
110 | |||
111 | //check if man has reached the base | ||
112 | void Man::checkCollision() | ||
113 | { | ||
114 | if ( (x() < 23) && (y() == canvas()->height()-26)) { | ||
115 | QCanvasItem* item; | ||
116 | QCanvasItemList l=collisions(FALSE); | ||
117 | for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) { | ||
118 | item = *it; | ||
119 | if ( (item->rtti()== 1800) && (item->collidesWith(this)) ) { | ||
120 | Base* base = (Base*) item; | ||
121 | base->damageBase(); | ||
122 | start(); | ||
123 | } | ||
124 | } | ||
125 | } | ||
126 | } | ||
127 | |||
128 | void Man::start() | ||
129 | { | ||
130 | setInitialCoords(); | ||
131 | move(dx, dy); | ||
132 | setFrame(5); | ||
133 | setZ(300); | ||
134 | show(); | ||
135 | |||
136 | static bool first_time = TRUE; | ||
137 | if (first_time) { | ||
138 | first_time = FALSE; | ||
139 | QTime midnight(0, 0, 0); | ||
140 | srand(midnight.secsTo(QTime::currentTime()) ); | ||
141 | } | ||
142 | int yfallspeed = 0; | ||
143 | yfallspeed = (rand() % 3) + 1; | ||
144 | setVelocity(0, yfallspeed); | ||
145 | } | ||
146 | |||
147 | void Man::done() | ||
148 | { | ||
149 | splat.play(); | ||
150 | count = 0; | ||
151 | dead = true; | ||
152 | setFrame(6); | ||
153 | } | ||
154 | |||
155 | int Man::getManCount() | ||
156 | { | ||
157 | return mancount; | ||
158 | } | ||
159 | |||
160 | void Man::setManCount(int count) | ||
161 | { | ||
162 | mancount = count; | ||
163 | } | ||
164 | |||
165 | |||
166 | int Man::rtti() const | ||
167 | { | ||
168 | return man_rtti; | ||
169 | } | ||
170 | |||
171 | Man::~Man() | ||
172 | { | ||
173 | mancount--; | ||
174 | } | ||
diff --git a/noncore/games/parashoot/man.h b/noncore/games/parashoot/man.h new file mode 100644 index 0000000..e48fc20 --- a/dev/null +++ b/noncore/games/parashoot/man.h | |||
@@ -0,0 +1,52 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
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 | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
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. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | #include <qpe/sound.h> | ||
22 | |||
23 | #include <qcanvas.h> | ||
24 | #include <qdatetime.h> | ||
25 | |||
26 | #include <stdlib.h> | ||
27 | |||
28 | class Man : public QCanvasSprite | ||
29 | { | ||
30 | |||
31 | public: | ||
32 | Man (QCanvas*); | ||
33 | Man (QCanvas*, int x, int y); | ||
34 | ~Man(); | ||
35 | void advance(int phase); | ||
36 | void setInitialCoords(); | ||
37 | void checkCollision(); | ||
38 | void start(); | ||
39 | void done(); | ||
40 | static int getManCount(); | ||
41 | static void setManCount(int count); | ||
42 | int rtti() const; | ||
43 | // int mancount; | ||
44 | |||
45 | private: | ||
46 | QCanvasPixmapArray* manarray; | ||
47 | int dx; | ||
48 | int dy; | ||
49 | bool dead; | ||
50 | int count; | ||
51 | Sound splat; | ||
52 | }; | ||
diff --git a/noncore/games/parashoot/parashoot.pro b/noncore/games/parashoot/parashoot.pro new file mode 100644 index 0000000..631560b --- a/dev/null +++ b/noncore/games/parashoot/parashoot.pro | |||
@@ -0,0 +1,11 @@ | |||
1 | TEMPLATE= app | ||
2 | CONFIG += qt warn_on release | ||
3 | DESTDIR = $(QPEDIR)/bin | ||
4 | HEADERS = interface.h man.h cannon.h base.h bullet.h helicopter.h | ||
5 | SOURCES = main.cpp interface.cpp man.cpp cannon.cpp base.cpp bullet.cpp helicopter.cpp | ||
6 | TARGET = parashoot | ||
7 | INCLUDEPATH += $(QPEDIR)/include | ||
8 | DEPENDPATH+= $(QPEDIR)/include | ||
9 | LIBS += -lqpe | ||
10 | |||
11 | TRANSLATIONS = ../i18n/de/parashoot.ts | ||
diff --git a/noncore/games/parashoot/qpe-parashoot.control b/noncore/games/parashoot/qpe-parashoot.control new file mode 100644 index 0000000..82e9421 --- a/dev/null +++ b/noncore/games/parashoot/qpe-parashoot.control | |||
@@ -0,0 +1,9 @@ | |||
1 | Files: bin/parashoot apps/Games/parashoot.desktop pics/parashoot | ||
2 | Priority: optional | ||
3 | Section: qpe/games | ||
4 | Maintainer: Warwick Allison <warwick@trolltech.com> | ||
5 | Architecture: arm | ||
6 | Version: $QPE_VERSION-3 | ||
7 | Depends: qpe-base ($QPE_VERSION) | ||
8 | Description: Game: shoot the parachutists | ||
9 | A game for the Qtopia environment. | ||