summaryrefslogtreecommitdiffstats
path: root/examples/statemachine/tankgameplugins
diff options
context:
space:
mode:
Diffstat (limited to 'examples/statemachine/tankgameplugins')
-rw-r--r--examples/statemachine/tankgameplugins/random_ai/random_ai.pro13
-rw-r--r--examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.cpp78
-rw-r--r--examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.h105
-rw-r--r--examples/statemachine/tankgameplugins/seek_ai/seek_ai.cpp89
-rw-r--r--examples/statemachine/tankgameplugins/seek_ai/seek_ai.h249
-rw-r--r--examples/statemachine/tankgameplugins/seek_ai/seek_ai.pro13
-rw-r--r--examples/statemachine/tankgameplugins/spin_ai/spin_ai.cpp70
-rw-r--r--examples/statemachine/tankgameplugins/spin_ai/spin_ai.h92
-rw-r--r--examples/statemachine/tankgameplugins/spin_ai/spin_ai.pro13
-rw-r--r--examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.cpp70
-rw-r--r--examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.h92
-rw-r--r--examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.pro13
-rw-r--r--examples/statemachine/tankgameplugins/tankgameplugins.pro11
13 files changed, 0 insertions, 908 deletions
diff --git a/examples/statemachine/tankgameplugins/random_ai/random_ai.pro b/examples/statemachine/tankgameplugins/random_ai/random_ai.pro
deleted file mode 100644
index 5bc0b26a0..000000000
--- a/examples/statemachine/tankgameplugins/random_ai/random_ai.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-INCLUDEPATH += ../..
-HEADERS = random_ai_plugin.h
-SOURCES = random_ai_plugin.cpp
-TARGET = $$qtLibraryTarget(random_ai)
-DESTDIR = ../../tankgame/plugins
-
-#! [0]
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgame/plugins
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS random_ai.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgameplugins/random_ai \ No newline at end of file
diff --git a/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.cpp b/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.cpp
deleted file mode 100644
index ddfd1c5b8..000000000
--- a/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (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 http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "random_ai_plugin.h"
-
-#include <QState>
-#include <QTime>
-#include <QtPlugin>
-
-QState *RandomAiPlugin::create(QState *parentState, QObject *tank)
-{
- qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
-
- QState *topLevel = new QState(parentState);
-
- QState *selectNextActionState = new SelectActionState(topLevel);
- topLevel->setInitialState(selectNextActionState);
-
- QState *fireState = new RandomDistanceState(topLevel);
- connect(fireState, SIGNAL(distanceComputed(qreal)), tank, SLOT(fireCannon()));
- selectNextActionState->addTransition(selectNextActionState, SIGNAL(fireSelected()), fireState);
-
- QState *moveForwardsState = new RandomDistanceState(topLevel);
- connect(moveForwardsState, SIGNAL(distanceComputed(qreal)), tank, SLOT(moveForwards(qreal)));
- selectNextActionState->addTransition(selectNextActionState, SIGNAL(moveForwardsSelected()), moveForwardsState);
-
- QState *moveBackwardsState = new RandomDistanceState(topLevel);
- connect(moveBackwardsState, SIGNAL(distanceComputed(qreal)), tank, SLOT(moveBackwards(qreal)));
- selectNextActionState->addTransition(selectNextActionState, SIGNAL(moveBackwardsSelected()), moveBackwardsState);
-
- QState *turnState = new RandomDistanceState(topLevel);
- connect(turnState, SIGNAL(distanceComputed(qreal)), tank, SLOT(turn(qreal)));
- selectNextActionState->addTransition(selectNextActionState, SIGNAL(turnSelected()), turnState);
-
- topLevel->addTransition(tank, SIGNAL(actionCompleted()), selectNextActionState);
-
- return topLevel;
-}
-
-Q_EXPORT_PLUGIN2(random_ai, RandomAiPlugin)
diff --git a/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.h b/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.h
deleted file mode 100644
index 4c3fc0f7c..000000000
--- a/examples/statemachine/tankgameplugins/random_ai/random_ai_plugin.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (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 http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef RANDOM_AI_PLUGIN_H
-#define RANDOM_AI_PLUGIN_H
-
-#include <QObject>
-#include <QState>
-
-#include <tankgame/plugin.h>
-
-class SelectActionState: public QState
-{
- Q_OBJECT
-public:
- SelectActionState(QState *parent = 0) : QState(parent)
- {
- }
-
-signals:
- void fireSelected();
- void moveForwardsSelected();
- void moveBackwardsSelected();
- void turnSelected();
-
-protected:
- void onEntry(QEvent *)
- {
- int rand = qrand() % 4;
- switch (rand) {
- case 0: emit fireSelected(); break;
- case 1: emit moveForwardsSelected(); break;
- case 2: emit moveBackwardsSelected(); break;
- case 3: emit turnSelected(); break;
- };
- }
-};
-
-class RandomDistanceState: public QState
-{
- Q_OBJECT
-public:
- RandomDistanceState(QState *parent = 0) : QState(parent)
- {
- }
-
-signals:
- void distanceComputed(qreal distance);
-
-protected:
- void onEntry(QEvent *)
- {
- emit distanceComputed(qreal(qrand() % 180));
- }
-};
-
-class RandomAiPlugin: public QObject, public Plugin
-{
- Q_OBJECT
- Q_INTERFACES(Plugin)
-public:
- RandomAiPlugin() { setObjectName("Random"); }
-
- virtual QState *create(QState *parentState, QObject *tank);
-};
-
-#endif // RANDOM_AI_PLUGIN_H
diff --git a/examples/statemachine/tankgameplugins/seek_ai/seek_ai.cpp b/examples/statemachine/tankgameplugins/seek_ai/seek_ai.cpp
deleted file mode 100644
index 79d7d0cea..000000000
--- a/examples/statemachine/tankgameplugins/seek_ai/seek_ai.cpp
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (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 http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "seek_ai.h"
-
-QState *SeekAi::create(QState *parentState, QObject *tank)
-{
- QState *topLevel = new QState(parentState);
- topLevel->setObjectName("topLevel");
-
- QState *seek = new QState(topLevel);
- seek->setObjectName("seek");
- topLevel->setInitialState(seek);
-
- QState *lookForNearestWall = new SearchState(tank, seek);
- lookForNearestWall->setObjectName("lookForNearestWall");
- seek->setInitialState(lookForNearestWall);
-
- QState *driveToFirstObstacle = new QState(seek);
- driveToFirstObstacle->setObjectName("driveToFirstObstacle");
- lookForNearestWall->addTransition(lookForNearestWall, SIGNAL(nearestObstacleStraightAhead()),
- driveToFirstObstacle);
-
- QState *drive = new QState(driveToFirstObstacle);
- drive->setObjectName("drive");
- driveToFirstObstacle->setInitialState(drive);
- connect(drive, SIGNAL(entered()), tank, SLOT(moveForwards()));
- connect(drive, SIGNAL(exited()), tank, SLOT(stop()));
-
- // Go in loop
- QState *finishedDriving = new QState(driveToFirstObstacle);
- finishedDriving->setObjectName("finishedDriving");
- drive->addTransition(tank, SIGNAL(actionCompleted()), finishedDriving);
- finishedDriving->addTransition(drive);
-
- QState *turnTo = new QState(seek);
- turnTo->setObjectName("turnTo");
- driveToFirstObstacle->addTransition(new CollisionTransition(tank, turnTo));
-
- turnTo->addTransition(tank, SIGNAL(actionCompleted()), driveToFirstObstacle);
-
- ChaseState *chase = new ChaseState(tank, topLevel);
- chase->setObjectName("chase");
- seek->addTransition(new TankSpottedTransition(tank, chase));
- chase->addTransition(chase, SIGNAL(finished()), driveToFirstObstacle);
- chase->addTransition(new TankSpottedTransition(tank, chase));
-
- return topLevel;
-}
-
-Q_EXPORT_PLUGIN2(seek_ai, SeekAi)
diff --git a/examples/statemachine/tankgameplugins/seek_ai/seek_ai.h b/examples/statemachine/tankgameplugins/seek_ai/seek_ai.h
deleted file mode 100644
index 1bc5b26ce..000000000
--- a/examples/statemachine/tankgameplugins/seek_ai/seek_ai.h
+++ /dev/null
@@ -1,249 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (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 http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef SEEK_AI_H
-#define SEEK_AI_H
-
-#include <tankgame/plugin.h>
-
-#include <QState>
-#include <QFinalState>
-#include <QSignalTransition>
-#include <QSignalEvent>
-#include <QVariant>
-#include <QLineF>
-#include <QDebug>
-
-class SearchState: public QState
-{
- Q_OBJECT
-public:
- SearchState(QObject *tank, QState *parentState = 0)
- : QState(parentState),
- m_tank(tank),
- m_distanceToTurn(360.0),
- m_nearestDistance(-1.0),
- m_directionOfNearestObstacle(0.0)
- {
- }
-
-public slots:
- void turnAlittle()
- {
- qreal dist = m_tank->property("distanceToObstacle").toDouble();
-
- if (m_nearestDistance < 0.0 || dist < m_nearestDistance) {
- m_nearestDistance = dist;
- m_directionOfNearestObstacle = m_tank->property("direction").toDouble();
- }
-
- m_distanceToTurn -= 10.0;
- if (m_distanceToTurn < 0.0) {
- disconnect(m_tank, SIGNAL(actionCompleted()), this, SLOT(turnAlittle()));
- connect(m_tank, SIGNAL(actionCompleted()), this, SIGNAL(nearestObstacleStraightAhead()));
- m_tank->setProperty("direction", m_directionOfNearestObstacle);
- }
-
- qreal currentDirection = m_tank->property("direction").toDouble();
- m_tank->setProperty("direction", currentDirection + 10.0);
- }
-
-signals:
- void nearestObstacleStraightAhead();
-
-protected:
- void onEntry(QEvent *)
- {
- connect(m_tank, SIGNAL(actionCompleted()), this, SLOT(turnAlittle()));
- turnAlittle();
- }
-
- void onExit(QEvent *)
- {
- disconnect(m_tank, SIGNAL(actionCompleted()), this, SLOT(turnAlittle()));
- disconnect(m_tank, SIGNAL(actionCompleted()), this, SLOT(nearestObstacleStraightAhead()));
- }
-
-private:
- QObject *m_tank;
-
- qreal m_distanceToTurn;
- qreal m_nearestDistance;
- qreal m_directionOfNearestObstacle;
-};
-
-class CollisionTransition: public QSignalTransition
-{
-public:
- CollisionTransition(QObject *tank, QState *turnTo)
- : QSignalTransition(tank, SIGNAL(collision(QLineF))),
- m_tank(tank),
- m_turnTo(turnTo)
- {
- setTargetState(turnTo);
- }
-
-protected:
- bool eventTest(QEvent *event)
- {
- bool b = QSignalTransition::eventTest(event);
- if (b) {
- QSignalEvent *se = static_cast<QSignalEvent *>(event);
- m_lastLine = se->arguments().at(0).toLineF();
- }
- return b;
- }
-
- void onTransition(QEvent *)
- {
- qreal angleOfWall = m_lastLine.angle();
-
- qreal newDirection;
- if (qrand() % 2 == 0)
- newDirection = angleOfWall;
- else
- newDirection = angleOfWall - 180.0;
-
- m_turnTo->assignProperty(m_tank, "direction", newDirection);
- }
-
-private:
- QLineF m_lastLine;
- QObject *m_tank;
- QState *m_turnTo;
-};
-
-class ChaseState: public QState
-{
- class GoToLocationState: public QState
- {
- public:
- GoToLocationState(QObject *tank, QState *parentState = 0)
- : QState(parentState), m_tank(tank), m_distance(0.0)
- {
- }
-
- void setDistance(qreal distance) { m_distance = distance; }
-
- protected:
- void onEntry()
- {
- QMetaObject::invokeMethod(m_tank, "moveForwards", Q_ARG(qreal, m_distance));
- }
-
- private:
- QObject *m_tank;
- qreal m_distance;
- };
-
-public:
- ChaseState(QObject *tank, QState *parentState = 0) : QState(parentState), m_tank(tank)
- {
- QState *fireCannon = new QState(this);
- fireCannon->setObjectName("fireCannon");
- connect(fireCannon, SIGNAL(entered()), tank, SLOT(fireCannon()));
- setInitialState(fireCannon);
-
- m_goToLocation = new GoToLocationState(tank, this);
- m_goToLocation->setObjectName("goToLocation");
- fireCannon->addTransition(tank, SIGNAL(actionCompleted()), m_goToLocation);
-
- m_turnToDirection = new QState(this);
- m_turnToDirection->setObjectName("turnToDirection");
- m_goToLocation->addTransition(tank, SIGNAL(actionCompleted()), m_turnToDirection);
-
- QFinalState *finalState = new QFinalState(this);
- finalState->setObjectName("finalState");
- m_turnToDirection->addTransition(tank, SIGNAL(actionCompleted()), finalState);
- }
-
- void setDirection(qreal direction)
- {
- m_turnToDirection->assignProperty(m_tank, "direction", direction);
- }
-
- void setDistance(qreal distance)
- {
- m_goToLocation->setDistance(distance);
- }
-
-private:
- QObject *m_tank;
- GoToLocationState *m_goToLocation;
- QState *m_turnToDirection;
-
-};
-
-class TankSpottedTransition: public QSignalTransition
-{
-public:
- TankSpottedTransition(QObject *tank, ChaseState *target) : QSignalTransition(tank, SIGNAL(tankSpotted(qreal,qreal))), m_chase(target)
- {
- setTargetState(target);
- }
-
-protected:
- bool eventTest(QEvent *event)
- {
- bool b = QSignalTransition::eventTest(event);
- if (b) {
- QSignalEvent *se = static_cast<QSignalEvent *>(event);
- m_chase->setDirection(se->arguments().at(0).toDouble());
- m_chase->setDistance(se->arguments().at(1).toDouble());
- }
- return b;
- }
-
-private:
- ChaseState *m_chase;
-};
-
-class SeekAi: public QObject, public Plugin
-{
- Q_OBJECT
- Q_INTERFACES(Plugin)
-public:
- SeekAi() { setObjectName("Seek and destroy"); }
-
- virtual QState *create(QState *parentState, QObject *tank);
-};
-
-#endif
diff --git a/examples/statemachine/tankgameplugins/seek_ai/seek_ai.pro b/examples/statemachine/tankgameplugins/seek_ai/seek_ai.pro
deleted file mode 100644
index 0d8bf2e9a..000000000
--- a/examples/statemachine/tankgameplugins/seek_ai/seek_ai.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-INCLUDEPATH += ../..
-HEADERS = seek_ai.h
-SOURCES = seek_ai.cpp
-TARGET = $$qtLibraryTarget(seek_ai)
-DESTDIR = ../../tankgame/plugins
-
-#! [0]
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgame/plugins
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS seek_ai.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgameplugins/seek_ai \ No newline at end of file
diff --git a/examples/statemachine/tankgameplugins/spin_ai/spin_ai.cpp b/examples/statemachine/tankgameplugins/spin_ai/spin_ai.cpp
deleted file mode 100644
index 4e7128533..000000000
--- a/examples/statemachine/tankgameplugins/spin_ai/spin_ai.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (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 http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "spin_ai.h"
-
-#include <QtPlugin>
-
-QState *SpinAi::create(QState *parentState, QObject *tank)
-{
- QState *topLevel = new QState(parentState);
- QState *spinState = new SpinState(tank, topLevel);
- topLevel->setInitialState(spinState);
-
- // When tank is spotted, fire two times and go back to spin state
- QState *fireState = new QState(topLevel);
-
- QState *fireOnce = new QState(fireState);
- fireState->setInitialState(fireOnce);
- connect(fireOnce, SIGNAL(entered()), tank, SLOT(fireCannon()));
-
- QState *fireTwice = new QState(fireState);
- connect(fireTwice, SIGNAL(entered()), tank, SLOT(fireCannon()));
-
- fireOnce->addTransition(tank, SIGNAL(actionCompleted()), fireTwice);
- fireTwice->addTransition(tank, SIGNAL(actionCompleted()), spinState);
-
- spinState->addTransition(tank, SIGNAL(tankSpotted(qreal,qreal)), fireState);
-
- return topLevel;
-}
-
-Q_EXPORT_PLUGIN2(spin_ai, SpinAi)
diff --git a/examples/statemachine/tankgameplugins/spin_ai/spin_ai.h b/examples/statemachine/tankgameplugins/spin_ai/spin_ai.h
deleted file mode 100644
index a97024d4c..000000000
--- a/examples/statemachine/tankgameplugins/spin_ai/spin_ai.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (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 http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef SPIN_AI_H
-#define SPIN_AI_H
-
-#include <tankgame/plugin.h>
-
-#include <QObject>
-#include <QState>
-#include <QVariant>
-
-class SpinState: public QState
-{
- Q_OBJECT
-public:
- SpinState(QObject *tank, QState *parent) : QState(parent), m_tank(tank)
- {
- }
-
-public slots:
- void spin()
- {
- m_tank->setProperty("direction", m_tank->property("direction").toDouble() + 90.0);
- }
-
-protected:
- void onEntry(QEvent *)
- {
- connect(m_tank, SIGNAL(actionCompleted()), this, SLOT(spin()));
- spin();
- }
-
- void onExit(QEvent *)
- {
- disconnect(m_tank, SIGNAL(actionCompleted()), this, SLOT(spin()));
- }
-
-private:
- QObject *m_tank;
-
-};
-
-class SpinAi: public QObject, public Plugin
-{
- Q_OBJECT
- Q_INTERFACES(Plugin)
-public:
- SpinAi() { setObjectName("Spin and destroy"); }
-
- virtual QState *create(QState *parentState, QObject *tank);
-};
-
-#endif
diff --git a/examples/statemachine/tankgameplugins/spin_ai/spin_ai.pro b/examples/statemachine/tankgameplugins/spin_ai/spin_ai.pro
deleted file mode 100644
index 8ab4da05f..000000000
--- a/examples/statemachine/tankgameplugins/spin_ai/spin_ai.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-INCLUDEPATH += ../..
-HEADERS = spin_ai.h
-SOURCES = spin_ai.cpp
-TARGET = $$qtLibraryTarget(spin_ai)
-DESTDIR = ../../tankgame/plugins
-
-#! [0]
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgame/plugins
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS spin_ai.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgameplugins/spin_ai \ No newline at end of file
diff --git a/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.cpp b/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.cpp
deleted file mode 100644
index 12a96567d..000000000
--- a/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (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 http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "spin_ai_with_error.h"
-
-#include <QtPlugin>
-
-QState *SpinAiWithError::create(QState *parentState, QObject *tank)
-{
- QState *topLevel = new QState(parentState);
- QState *spinState = new SpinState(tank, topLevel);
- topLevel->setInitialState(spinState);
-
- // When tank is spotted, fire two times and go back to spin state
- // (no initial state set for fireState will lead to run-time error in machine)
- QState *fireState = new QState(topLevel);
-
- QState *fireOnce = new QState(fireState);
- connect(fireOnce, SIGNAL(entered()), tank, SLOT(fireCannon()));
-
- QState *fireTwice = new QState(fireState);
- connect(fireTwice, SIGNAL(entered()), tank, SLOT(fireCannon()));
-
- fireOnce->addTransition(tank, SIGNAL(actionCompleted()), fireTwice);
- fireTwice->addTransition(tank, SIGNAL(actionCompleted()), spinState);
-
- spinState->addTransition(tank, SIGNAL(tankSpotted(qreal,qreal)), fireState);
-
- return topLevel;
-}
-
-Q_EXPORT_PLUGIN2(spin_ai_with_error, SpinAiWithError)
diff --git a/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.h b/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.h
deleted file mode 100644
index f35da268e..000000000
--- a/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (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 http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef SPIN_AI_WITH_ERROR_H
-#define SPIN_AI_WITH_ERROR_H
-
-#include <tankgame/plugin.h>
-
-#include <QObject>
-#include <QState>
-#include <QVariant>
-
-class SpinState: public QState
-{
- Q_OBJECT
-public:
- SpinState(QObject *tank, QState *parent) : QState(parent), m_tank(tank)
- {
- }
-
-public slots:
- void spin()
- {
- m_tank->setProperty("direction", m_tank->property("direction").toDouble() + 90.0);
- }
-
-protected:
- void onEntry(QEvent *)
- {
- connect(m_tank, SIGNAL(actionCompleted()), this, SLOT(spin()));
- spin();
- }
-
- void onExit(QEvent *)
- {
- disconnect(m_tank, SIGNAL(actionCompleted()), this, SLOT(spin()));
- }
-
-private:
- QObject *m_tank;
-
-};
-
-class SpinAiWithError: public QObject, public Plugin
-{
- Q_OBJECT
- Q_INTERFACES(Plugin)
-public:
- SpinAiWithError() { setObjectName("Spin and destroy with runtime error in state machine"); }
-
- virtual QState *create(QState *parentState, QObject *tank);
-};
-
-#endif
diff --git a/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.pro b/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.pro
deleted file mode 100644
index 124cf98d1..000000000
--- a/examples/statemachine/tankgameplugins/spin_ai_with_error/spin_ai_with_error.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-INCLUDEPATH += ../..
-HEADERS = spin_ai_with_error.h
-SOURCES = spin_ai_with_error.cpp
-TARGET = $$qtLibraryTarget(spin_ai_with_error)
-DESTDIR = ../../tankgame/plugins
-
-#! [0]
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgame/plugins
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS spin_ai_with_error.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgameplugins/spin_ai_with_error \ No newline at end of file
diff --git a/examples/statemachine/tankgameplugins/tankgameplugins.pro b/examples/statemachine/tankgameplugins/tankgameplugins.pro
deleted file mode 100644
index a098e03c8..000000000
--- a/examples/statemachine/tankgameplugins/tankgameplugins.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS = random_ai \
- spin_ai_with_error \
- spin_ai \
- seek_ai
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgameplugins
-sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS tankgameplugins.pro
-sources.path = $$[QT_INSTALL_EXAMPLES]/statemachine/tankgameplugins
-INSTALLS += target sources