summaryrefslogtreecommitdiffstats
path: root/examples/statemachine/tankgame
diff options
context:
space:
mode:
authorJason McDonald <jason.mcdonald@nokia.com>2009-05-21 07:04:38 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2009-05-21 07:04:38 (GMT)
commitb0078f00058f8d2a9fbe4742f52386a866b2bd97 (patch)
treebc102b7f8b50e0cb32ffd2af8a7fd6cda736818a /examples/statemachine/tankgame
parentbbd7c13d0cf9d99413f2bea9a3acfba848e3520e (diff)
downloadQt-b0078f00058f8d2a9fbe4742f52386a866b2bd97.zip
Qt-b0078f00058f8d2a9fbe4742f52386a866b2bd97.tar.gz
Qt-b0078f00058f8d2a9fbe4742f52386a866b2bd97.tar.bz2
Fix missing/outdated license headers.
Reviewed-by: Trust Me
Diffstat (limited to 'examples/statemachine/tankgame')
-rw-r--r--examples/statemachine/tankgame/gameitem.cpp41
-rw-r--r--examples/statemachine/tankgame/gameitem.h41
-rw-r--r--examples/statemachine/tankgame/gameovertransition.cpp45
-rw-r--r--examples/statemachine/tankgame/gameovertransition.h41
-rw-r--r--examples/statemachine/tankgame/main.cpp41
-rw-r--r--examples/statemachine/tankgame/mainwindow.cpp81
-rw-r--r--examples/statemachine/tankgame/mainwindow.h45
-rw-r--r--examples/statemachine/tankgame/plugin.h41
-rw-r--r--examples/statemachine/tankgame/rocketitem.cpp43
-rw-r--r--examples/statemachine/tankgame/rocketitem.h44
-rw-r--r--examples/statemachine/tankgame/tankitem.cpp73
-rw-r--r--examples/statemachine/tankgame/tankitem.h47
12 files changed, 536 insertions, 47 deletions
diff --git a/examples/statemachine/tankgame/gameitem.cpp b/examples/statemachine/tankgame/gameitem.cpp
index 1a2af71..ad8b37c 100644
--- a/examples/statemachine/tankgame/gameitem.cpp
+++ b/examples/statemachine/tankgame/gameitem.cpp
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
#include "gameitem.h"
#include <QGraphicsScene>
diff --git a/examples/statemachine/tankgame/gameitem.h b/examples/statemachine/tankgame/gameitem.h
index 33caf71..90b0a6c 100644
--- a/examples/statemachine/tankgame/gameitem.h
+++ b/examples/statemachine/tankgame/gameitem.h
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
#ifndef GAMEITEM_H
#define GAMEITEM_H
diff --git a/examples/statemachine/tankgame/gameovertransition.cpp b/examples/statemachine/tankgame/gameovertransition.cpp
index cec786e..360e902 100644
--- a/examples/statemachine/tankgame/gameovertransition.cpp
+++ b/examples/statemachine/tankgame/gameovertransition.cpp
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
#include "gameovertransition.h"
#include "tankitem.h"
@@ -8,7 +49,7 @@ GameOverTransition::GameOverTransition(QAbstractState *targetState)
: QSignalTransition(new QSignalMapper(), SIGNAL(mapped(QObject*)))
{
setTargetState(targetState);
-
+
QSignalMapper *mapper = qobject_cast<QSignalMapper *>(senderObject());
mapper->setParent(this);
}
@@ -36,4 +77,4 @@ bool GameOverTransition::eventTest(QEvent *e)
} else {
return false;
}
-} \ No newline at end of file
+}
diff --git a/examples/statemachine/tankgame/gameovertransition.h b/examples/statemachine/tankgame/gameovertransition.h
index 9a86b83..5e99a75 100644
--- a/examples/statemachine/tankgame/gameovertransition.h
+++ b/examples/statemachine/tankgame/gameovertransition.h
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
#ifndef GAMEOVERTRANSITION_H
#define GAMEOVERTRANSITION_H
diff --git a/examples/statemachine/tankgame/main.cpp b/examples/statemachine/tankgame/main.cpp
index 26fc1bb..185ad68 100644
--- a/examples/statemachine/tankgame/main.cpp
+++ b/examples/statemachine/tankgame/main.cpp
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
#include <QApplication>
#include "mainwindow.h"
diff --git a/examples/statemachine/tankgame/mainwindow.cpp b/examples/statemachine/tankgame/mainwindow.cpp
index 3437140..46e0db3 100644
--- a/examples/statemachine/tankgame/mainwindow.cpp
+++ b/examples/statemachine/tankgame/mainwindow.cpp
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
#include "mainwindow.h"
#include "tankitem.h"
#include "rocketitem.h"
@@ -97,7 +138,7 @@ void MainWindow::init()
addWall(QRectF(centerOfMap - QPointF(-50.0, -60.0), centerOfMap - QPointF(50.0, -50.0)));
addWall(QRectF(centerOfMap + QPointF(-50.0, -50.0), centerOfMap + QPointF(-40.0, 50.0)));
addWall(QRectF(centerOfMap - QPointF(-50.0, -50.0), centerOfMap - QPointF(-40.0, 50.0)));
-
+
addWall(QRectF(sceneRect.topLeft() + QPointF(sceneRect.width() / 2.0 - 5.0, -10.0),
sceneRect.topLeft() + QPointF(sceneRect.width() / 2.0 + 5.0, 100.0)));
addWall(QRectF(sceneRect.bottomLeft() + QPointF(sceneRect.width() / 2.0 - 5.0, 10.0),
@@ -108,18 +149,18 @@ void MainWindow::init()
sceneRect.topRight() + QPointF(-100.0, sceneRect.height() / 2.0 + 5.0)));
- QAction *addTankAction = menuBar()->addAction("&Add tank");
- QAction *runGameAction = menuBar()->addAction("&Run game");
+ QAction *addTankAction = menuBar()->addAction("&Add tank");
+ QAction *runGameAction = menuBar()->addAction("&Run game");
runGameAction->setObjectName("runGameAction");
- QAction *stopGameAction = menuBar()->addAction("&Stop game");
+ QAction *stopGameAction = menuBar()->addAction("&Stop game");
menuBar()->addSeparator();
QAction *quitAction = menuBar()->addAction("&Quit");
-
+
connect(addTankAction, SIGNAL(triggered()), this, SLOT(addTank()));
connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
-
- m_machine = new QStateMachine(this);
- QState *stoppedState = new QState(m_machine->rootState());
+
+ m_machine = new QStateMachine(this);
+ QState *stoppedState = new QState(m_machine->rootState());
stoppedState->setObjectName("stoppedState");
stoppedState->assignProperty(runGameAction, "enabled", true);
stoppedState->assignProperty(stopGameAction, "enabled", false);
@@ -127,19 +168,19 @@ void MainWindow::init()
m_machine->setInitialState(stoppedState);
//! [5]
- QState *spawnsAvailable = new QState(stoppedState);
+ QState *spawnsAvailable = new QState(stoppedState);
spawnsAvailable->assignProperty(addTankAction, "enabled", true);
- QState *noSpawnsAvailable = new QState(stoppedState);
+ QState *noSpawnsAvailable = new QState(stoppedState);
noSpawnsAvailable->assignProperty(addTankAction, "enabled", false);
-//! [5]
+//! [5]
spawnsAvailable->setObjectName("spawnsAvailable");
noSpawnsAvailable->setObjectName("noSpawnsAvailable");
spawnsAvailable->addTransition(this, SIGNAL(mapFull()), noSpawnsAvailable);
//! [3]
- QHistoryState *hs = new QHistoryState(stoppedState);
+ QHistoryState *hs = new QHistoryState(stoppedState);
hs->setDefaultState(spawnsAvailable);
//! [3]
hs->setObjectName("hs");
@@ -158,7 +199,7 @@ void MainWindow::init()
gameOverState->setObjectName("gameOverState");
gameOverState->assignProperty(stopGameAction, "enabled", false);
connect(gameOverState, SIGNAL(entered()), this, SLOT(gameOver()));
-
+
stoppedState->addTransition(runGameAction, SIGNAL(triggered()), m_runningState);
m_runningState->addTransition(stopGameAction, SIGNAL(triggered()), stoppedState);
@@ -168,12 +209,12 @@ void MainWindow::init()
QTimer *timer = new QTimer(this);
timer->setInterval(100);
connect(timer, SIGNAL(timeout()), this, SLOT(runStep()));
- connect(m_runningState, SIGNAL(entered()), timer, SLOT(start()));
+ connect(m_runningState, SIGNAL(entered()), timer, SLOT(start()));
connect(m_runningState, SIGNAL(exited()), timer, SLOT(stop()));
m_machine->start();
m_time.start();
-}
+}
void MainWindow::runStep()
{
@@ -206,7 +247,7 @@ void MainWindow::gameOver()
}
}
- QMessageBox::information(this, "Game over!",
+ QMessageBox::information(this, "Game over!",
QString::fromLatin1("The tank played by '%1' has won!").arg(lastTankStanding->objectName()));
}
@@ -216,7 +257,7 @@ void MainWindow::addRocket()
if (tankItem != 0) {
RocketItem *rocketItem = new RocketItem;
- QPointF s = tankItem->mapToScene(QPointF(tankItem->boundingRect().right() + 10.0,
+ QPointF s = tankItem->mapToScene(QPointF(tankItem->boundingRect().right() + 10.0,
tankItem->boundingRect().center().y()));
rocketItem->setPos(s);
rocketItem->setDirection(tankItem->direction());
@@ -264,10 +305,10 @@ void MainWindow::addTank()
bool ok;
//! [1]
- QString selectedName = QInputDialog::getItem(this, "Select a tank type", "Tank types",
+ QString selectedName = QInputDialog::getItem(this, "Select a tank type", "Tank types",
itemNames, 0, false, &ok);
//! [1]
-
+
if (ok && !selectedName.isEmpty()) {
int idx = itemNames.indexOf(selectedName);
if (Plugin *plugin = idx >= 0 ? items.at(idx) : 0) {
@@ -280,7 +321,7 @@ void MainWindow::addTank()
emit mapFull();
m_gameOverTransition->addTankItem(tankItem);
-
+
QState *region = new QState(m_runningState);
region->setObjectName(QString::fromLatin1("region%1").arg(m_spawns.size()));
//! [2]
diff --git a/examples/statemachine/tankgame/mainwindow.h b/examples/statemachine/tankgame/mainwindow.h
index 391ab77..4ae8f7a 100644
--- a/examples/statemachine/tankgame/mainwindow.h
+++ b/examples/statemachine/tankgame/mainwindow.h
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
@@ -37,14 +78,14 @@ private:
void addWall(const QRectF &wall);
QGraphicsScene *m_scene;
-
+
QStateMachine *m_machine;
QState *m_runningState;
GameOverTransition *m_gameOverTransition;
QList<TankItem *> m_spawns;
QTime m_time;
-
+
bool m_started : 1;
};
diff --git a/examples/statemachine/tankgame/plugin.h b/examples/statemachine/tankgame/plugin.h
index 006ad78..ddd10b7 100644
--- a/examples/statemachine/tankgame/plugin.h
+++ b/examples/statemachine/tankgame/plugin.h
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
#ifndef PLUGIN_H
#define PLUGIN_H
diff --git a/examples/statemachine/tankgame/rocketitem.cpp b/examples/statemachine/tankgame/rocketitem.cpp
index c324980..3ace8e8 100644
--- a/examples/statemachine/tankgame/rocketitem.cpp
+++ b/examples/statemachine/tankgame/rocketitem.cpp
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
#include "rocketitem.h"
#include "tankitem.h"
@@ -53,7 +94,7 @@ void RocketItem::idle(qreal elapsed)
if (tankItem != 0)
tankItem->hitByRocket();
}
-
+
scene()->removeItem(this);
delete this;
}
diff --git a/examples/statemachine/tankgame/rocketitem.h b/examples/statemachine/tankgame/rocketitem.h
index 189a1dd..31146a6 100644
--- a/examples/statemachine/tankgame/rocketitem.h
+++ b/examples/statemachine/tankgame/rocketitem.h
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
#ifndef ROCKETITEM_H
#define ROCKETITEM_H
@@ -12,7 +53,7 @@ public:
virtual void idle(qreal elapsed);
qreal speed() const { return 100.0; }
void setDirection(qreal direction) { m_direction = direction; }
-
+
protected:
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
QRectF boundingRect() const;
@@ -22,5 +63,4 @@ private:
qreal m_distance;
};
-
#endif
diff --git a/examples/statemachine/tankgame/tankitem.cpp b/examples/statemachine/tankgame/tankitem.cpp
index c322d21..393d65f 100644
--- a/examples/statemachine/tankgame/tankitem.cpp
+++ b/examples/statemachine/tankgame/tankitem.cpp
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
#include "tankitem.h"
#include <QPainter>
@@ -35,15 +76,15 @@ public:
m_reverse = m_distance < 0.0;
}
- bool apply(qreal timeDelta)
+ bool apply(qreal timeDelta)
{
qreal dist = timeDelta * item()->speed() * (m_reverse ? -1.0 : 1.0);
- bool done = false;
- if (qAbs(m_distance) < qAbs(dist)) {
+ bool done = false;
+ if (qAbs(m_distance) < qAbs(dist)) {
done = true;
dist = m_distance;
- }
+ }
m_distance -= dist;
qreal a = item()->direction() * M_PI / 180.0;
@@ -69,14 +110,14 @@ public:
m_reverse = m_distance < 0.0;
}
- bool apply(qreal timeDelta)
+ bool apply(qreal timeDelta)
{
qreal dist = timeDelta * item()->angularSpeed() * (m_reverse ? -1.0 : 1.0);
- bool done = false;
+ bool done = false;
if (qAbs(m_distance) < qAbs(dist)) {
done = true;
dist = m_distance;
- }
+ }
m_distance -= dist;
item()->setDirection(item()->direction() + dist);
@@ -88,7 +129,7 @@ private:
bool m_reverse;
};
-TankItem::TankItem(QObject *parent)
+TankItem::TankItem(QObject *parent)
: GameItem(parent), m_currentAction(0), m_currentDirection(0.0), m_enabled(true)
{
connect(this, SIGNAL(cannonFired()), this, SIGNAL(actionCompleted()));
@@ -106,7 +147,7 @@ void TankItem::idle(qreal elapsed)
QGraphicsItem *item = 0;
qreal distance = distanceToObstacle(&item);
if (TankItem *tankItem = qgraphicsitem_cast<TankItem *>(item))
- emit tankSpotted(tankItem->direction(), distance);
+ emit tankSpotted(tankItem->direction(), distance);
}
}
}
@@ -119,7 +160,7 @@ void TankItem::hitByRocket()
void TankItem::setAction(Action *newAction)
{
- if (m_currentAction != 0)
+ if (m_currentAction != 0)
delete m_currentAction;
m_currentAction = newAction;
@@ -184,9 +225,9 @@ void TankItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidge
QRectF cannonBase = brect.adjusted(10.0, 6.0, -12.0, -6.0);
painter->drawEllipse(cannonBase);
- painter->drawRect(QRectF(QPointF(cannonBase.center().x(), cannonBase.center().y() - 2.0),
+ painter->drawRect(QRectF(QPointF(cannonBase.center().x(), cannonBase.center().y() - 2.0),
QPointF(brect.right(), cannonBase.center().y() + 2.0)));
-
+
// left track
painter->setBrush(QBrush(Qt::black, Qt::VerPattern));
QRectF leftTrackRect = QRectF(brect.topLeft(), QPointF(brect.right() - 2.0, brect.top() + 4.0));
@@ -223,7 +264,7 @@ qreal TankItem::direction() const
void TankItem::setDirection(qreal newDirection)
{
- int fullRotations = int(newDirection) / 360;
+ int fullRotations = int(newDirection) / 360;
newDirection -= fullRotations * 360.0;
qreal diff = newDirection - m_currentDirection;
@@ -245,8 +286,8 @@ qreal TankItem::distanceToObstacle(QGraphicsItem **obstacle) const
QPointF nextPosition = tryMove(requestedPosition, 0, &collidedItem);
if (collidedItem != 0) {
if (obstacle != 0)
- *obstacle = collidedItem;
-
+ *obstacle = collidedItem;
+
QPointF d = nextPosition - pos();
return sqrt(pow(d.x(), 2) + pow(d.y(), 2));
} else {
@@ -259,5 +300,3 @@ qreal TankItem::distanceToObstacle() const
return distanceToObstacle(0);
}
-
-
diff --git a/examples/statemachine/tankgame/tankitem.h b/examples/statemachine/tankgame/tankitem.h
index 9475397..942fca8 100644
--- a/examples/statemachine/tankgame/tankitem.h
+++ b/examples/statemachine/tankgame/tankitem.h
@@ -1,3 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
#ifndef TANKITEM_H
#define TANKITEM_H
@@ -12,9 +53,9 @@ class TankItem: public GameItem
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled)
Q_PROPERTY(qreal direction READ direction WRITE turnTo)
Q_PROPERTY(qreal distanceToObstacle READ distanceToObstacle)
-public:
+public:
TankItem(QObject *parent = 0);
-
+
void setColor(const QColor &color) { m_color = color; }
QColor color() const { return m_color; }
@@ -53,7 +94,7 @@ public slots:
//! [0]
protected:
- virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+ virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
QVariant itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value);
private: