summaryrefslogtreecommitdiff
path: root/noncore/games/parashoot/interface.cpp
Side-by-side diff
Diffstat (limited to 'noncore/games/parashoot/interface.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/parashoot/interface.cpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/noncore/games/parashoot/interface.cpp b/noncore/games/parashoot/interface.cpp
index db98720..a40426d 100644
--- a/noncore/games/parashoot/interface.cpp
+++ b/noncore/games/parashoot/interface.cpp
@@ -19,26 +19,29 @@
**********************************************************************/
#include "interface.h"
#include "man.h"
#include <qpe/resource.h>
+#include <qpe/qpeapplication.h>
#include <qlabel.h>
#include <qmessagebox.h>
#include <qapplication.h>
#include <qstyle.h>
#include <qpe/qpetoolbar.h>
#include <qtoolbutton.h>
-
+
ParaShoot::ParaShoot(QWidget* parent, const char* name, WFlags f) :
QMainWindow(parent,name,f),
canvas(232, 258),
fanfare("level_up"),
score(0)
{
+ QPEApplication::grabKeyboard();
+ QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff );
canvas.setAdvancePeriod(80);
QPixmap bg = Resource::loadPixmap("parashoot/sky");
canvas.setBackgroundPixmap(bg);
pb = new QCanvasView(&canvas, this);
pb->setFocus();
@@ -56,20 +59,20 @@ ParaShoot::ParaShoot(QWidget* parent, const char* name, WFlags f) :
levelscore = new QLabel(toolbar);
levelscore->setBackgroundMode( PaletteButton );
levelscore->setAlignment( AlignRight | AlignVCenter | ExpandTabs );
toolbar->setStretchableWidget( levelscore );
showScore(0,0);
-
+
setCentralWidget(pb);
autoDropTimer = new QTimer(this);
connect (autoDropTimer, SIGNAL(timeout()), this, SLOT(play()) );
-
+
pauseTimer = new QTimer(this);
- connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) );
+ connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) );
setFocusPolicy(StrongFocus);
newGame();
}
@@ -88,13 +91,13 @@ void ParaShoot::showScore( int score, int level )
}
void ParaShoot::newGame()
{
clear();
- if (pauseTimer->isActive())
+ if (pauseTimer->isActive())
pauseTimer->stop();
clear();
Man::setManCount(0);
score = 0;
Bullet::setShotCount(0);
Bullet::setNobullets(0);
@@ -116,38 +119,38 @@ void ParaShoot::newGame()
void ParaShoot::clear()
{
autoDropTimer->stop();
// QCanvasItem* item;
QCanvasItemList l = canvas.allItems();
for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) {
- delete *it;
+ delete *it;
}
}
void ParaShoot::gameOver()
{
QCanvasItem* item;
QCanvasItemList l = canvas.allItems();
- for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) {
+ for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) {
item = *it;
if ((item->rtti()==1500) || (item->rtti()==1600) || item->rtti()==1900)
item->setAnimated(false);
}
autoDropTimer->stop();
Helicopter::silenceAll();
int shots = Bullet::getShotCount();
int shotsFired = cannon->shotsFired();
- if ( shotsFired == 0 )
+ if ( shotsFired == 0 )
shotsFired = 1;
QCanvasText* gameover = new QCanvasText(
tr( " GAME OVER!\n"
" Your Score: %1\n"
" Parachuters Killed: %2\n"
- " Accuracy: %3% " ).arg(score).arg(shots).arg(shots * 100 / shotsFired ),
+ " Accuracy: %3% " ).arg(score).arg(shots).arg(shots * 100 / shotsFired ),
&canvas);
gameover->setColor(red);
gameover->setFont( QFont("times", 18, QFont::Bold) );
gameover->move(canvas.width()/2 -110, canvas.height()/2 -50);
gameover->setZ(500);
gameover->show();
@@ -160,13 +163,13 @@ void ParaShoot::wait()
{
waitover = true;
pauseTimer->stop();
}
void ParaShoot::play()
-{
+{
if (Man::getManCount() < nomen ) {
new Man(&canvas);
}
if (Base::baseDestroyed()) {
gameOver();
return;
@@ -174,33 +177,33 @@ void ParaShoot::play()
}
void ParaShoot::increaseScore(int x)
{
score += x;
if ( score / 150 != (score-x) / 150 )
- levelUp();
+ levelUp();
showScore(level,score);
}
void ParaShoot::levelUp()
{
- level++;
+ level++;
int stage = level % 3;
switch(stage) {
case 0:
nomen++;
Bullet::setLimit(nomen);
fanfare.play();
break;
case 1:
new Helicopter(&canvas);
- break;
+ break;
case 2:
moveFaster();
fanfare.play();
- break;
+ break;
default: return;
}
}
void ParaShoot::moveFaster()
{
@@ -213,13 +216,13 @@ void ParaShoot::moveFaster()
void ParaShoot::keyPressEvent(QKeyEvent* event)
{
if (gamestopped) {
if (waitover)
newGame();
- else
+ else
return;
} else {
switch(event->key()) {
case Key_Up:
case Key_F1:
case Key_F9: