diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2009-03-23 09:18:55 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2009-03-23 09:18:55 (GMT) |
commit | e5fcad302d86d316390c6b0f62759a067313e8a9 (patch) | |
tree | c2afbf6f1066b6ce261f14341cf6d310e5595bc1 /examples/graphicsview/portedasteroids | |
download | Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.zip Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.gz Qt-e5fcad302d86d316390c6b0f62759a067313e8a9.tar.bz2 |
Long live Qt 4.5!
Diffstat (limited to 'examples/graphicsview/portedasteroids')
182 files changed, 2950 insertions, 0 deletions
diff --git a/examples/graphicsview/portedasteroids/animateditem.cpp b/examples/graphicsview/portedasteroids/animateditem.cpp new file mode 100644 index 0000000..ac41fb5 --- /dev/null +++ b/examples/graphicsview/portedasteroids/animateditem.cpp @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** 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 "animateditem.h" + +#include <QtGui/qbitmap.h> +#include <QtGui/qpainter.h> + +AnimatedPixmapItem::AnimatedPixmapItem(const QList<QPixmap> &animation, + QGraphicsScene *scene) + : QGraphicsItem(0, scene), currentFrame(0), vx(0), vy(0) +{ + for (int i = 0; i < animation.size(); ++i) { + QPixmap pixmap = animation.at(i); + Frame frame; + frame.pixmap = pixmap; + frame.shape = QPainterPath(); + frame.boundingRect = pixmap.rect(); + frames << frame; + } +} + +void AnimatedPixmapItem::setFrame(int frame) +{ + if (!frames.isEmpty()) { + prepareGeometryChange(); + currentFrame = frame % frames.size(); + } +} + +void AnimatedPixmapItem::advance(int phase) +{ + if (phase == 1) + moveBy(vx, vy); +} + +QRectF AnimatedPixmapItem::boundingRect() const +{ + return frames.at(currentFrame).boundingRect; +} + +QPainterPath AnimatedPixmapItem::shape() const +{ + const Frame &f = frames.at(currentFrame); + if (f.shape.isEmpty()) { + QPainterPath path; + path.addRegion(f.pixmap.createHeuristicMask()); + const_cast<Frame &>(f).shape = path; + } + return f.shape; +} + +void AnimatedPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*option*/, + QWidget * /*widget*/) +{ + painter->drawPixmap(0, 0, frames.at(currentFrame).pixmap); +} diff --git a/examples/graphicsview/portedasteroids/animateditem.h b/examples/graphicsview/portedasteroids/animateditem.h new file mode 100644 index 0000000..54e8e56 --- /dev/null +++ b/examples/graphicsview/portedasteroids/animateditem.h @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** 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 ANIMATEDPIXMAPITEM_H +#define ANIMATEDPIXMAPITEM_H + +#include <QGraphicsItem> + +class AnimatedPixmapItem : public QGraphicsItem +{ +public: + AnimatedPixmapItem(const QList<QPixmap> &animation, QGraphicsScene *scene = 0); + + void setFrame(int frame); + inline int frame() const + { return currentFrame; } + inline int frameCount() const + { return frames.size(); } + inline QPixmap image(int frame) const + { return frames.isEmpty() ? QPixmap() : frames.at(frame % frames.size()).pixmap; } + inline void setVelocity(qreal xvel, qreal yvel) + { vx = xvel; vy = yvel; } + inline qreal xVelocity() const + { return vx; } + inline qreal yVelocity() const + { return vy; } + + QRectF boundingRect() const; + QPainterPath shape() const; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + + void advance(int phase); + +private: + struct Frame { + QPixmap pixmap; + QPainterPath shape; + QRectF boundingRect; + }; + + int currentFrame; + QList<Frame> frames; + qreal vx, vy; +}; + +#endif diff --git a/examples/graphicsview/portedasteroids/bg.png b/examples/graphicsview/portedasteroids/bg.png Binary files differnew file mode 100644 index 0000000..1201172 --- /dev/null +++ b/examples/graphicsview/portedasteroids/bg.png diff --git a/examples/graphicsview/portedasteroids/ledmeter.cpp b/examples/graphicsview/portedasteroids/ledmeter.cpp new file mode 100644 index 0000000..37aee26 --- /dev/null +++ b/examples/graphicsview/portedasteroids/ledmeter.cpp @@ -0,0 +1,161 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +/* + * KAsteroids - Copyright (c) Martin R. Jones 1997 + * + * Part of the KDE project + */ + +#include <qpainter.h> +//Added by qt3to4: +#include <QResizeEvent> +#include <Q3Frame> +#include "ledmeter.h" + +KALedMeter::KALedMeter( QWidget *parent ) : Q3Frame( parent ) +{ + mCRanges.setAutoDelete( TRUE ); + mRange = 100; + mCount = 20; + mCurrentCount = 0; + mValue = 0; + setMinimumWidth( mCount * 2 + frameWidth() ); +} + +void KALedMeter::setRange( int r ) +{ + mRange = r; + if ( mRange < 1 ) + mRange = 1; + setValue( mValue ); + update(); +} + +void KALedMeter::setCount( int c ) +{ + mCount = c; + if ( mCount < 1 ) + mCount = 1; + setMinimumWidth( mCount * 2 + frameWidth() ); + calcColorRanges(); + setValue( mValue ); + update(); +} + +void KALedMeter::setValue( int v ) +{ + mValue = v; + if ( mValue > mRange ) + mValue = mRange; + else if ( mValue < 0 ) + mValue = 0; + int c = ( mValue + mRange / mCount - 1 ) * mCount / mRange; + if ( c != mCurrentCount ) + { + mCurrentCount = c; + update(); + } +} + +void KALedMeter::addColorRange( int pc, const QColor &c ) +{ + ColorRange *cr = new ColorRange; + cr->mPc = pc; + cr->mColor = c; + mCRanges.append( cr ); + calcColorRanges(); +} + +void KALedMeter::resizeEvent( QResizeEvent *e ) +{ + Q3Frame::resizeEvent( e ); + int w = ( width() - frameWidth() - 2 ) / mCount * mCount; + w += frameWidth() + 2; + setFrameRect( QRect( 0, 0, w, height() ) ); +} + +void KALedMeter::drawContents( QPainter *p ) +{ + QRect b = contentsRect(); + + unsigned cidx = 0; + int ncol = mCount; + QColor col = colorGroup().foreground(); + + if ( !mCRanges.isEmpty() ) + { + col = mCRanges.at( cidx )->mColor; + ncol = mCRanges.at( cidx )->mValue; + } + p->setBrush( col ); + p->setPen( col ); + + int lw = b.width() / mCount; + int lx = b.left() + 1; + for ( int i = 0; i < mCurrentCount; i++, lx += lw ) + { + if ( i > ncol ) + { + if ( ++cidx < mCRanges.count() ) + { + col = mCRanges.at( cidx )->mColor; + ncol = mCRanges.at( cidx )->mValue; + p->setBrush( col ); + p->setPen( col ); + } + } + + p->drawRect( lx, b.top() + 1, lw - 1, b.height() - 2 ); + } +} + +void KALedMeter::calcColorRanges() +{ + int prev = 0; + ColorRange *cr; + for ( cr = mCRanges.first(); cr; cr = mCRanges.next() ) + { + cr->mValue = prev + cr->mPc * mCount / 100; + prev = cr->mValue; + } +} + diff --git a/examples/graphicsview/portedasteroids/ledmeter.h b/examples/graphicsview/portedasteroids/ledmeter.h new file mode 100644 index 0000000..117b113 --- /dev/null +++ b/examples/graphicsview/portedasteroids/ledmeter.h @@ -0,0 +1,96 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +/* + * KAsteroids - Copyright (c) Martin R. Jones 1997 + * + * Part of the KDE project + */ + +#ifndef __LEDMETER_H__ +#define __LEDMETER_H__ + +#include <q3frame.h> +#include <q3ptrlist.h> +//Added by qt3to4: +#include <QResizeEvent> + + +class KALedMeter : public Q3Frame +{ + Q_OBJECT +public: + KALedMeter( QWidget *parent ); + + int range() const { return mRange; } + void setRange( int r ); + + int count() const { return mCount; } + void setCount( int c ); + + int value () const { return mValue; } + + void addColorRange( int pc, const QColor &c ); + +public slots: + void setValue( int v ); + +protected: + virtual void resizeEvent( QResizeEvent * ); + virtual void drawContents( QPainter * ); + void calcColorRanges(); + +protected: + struct ColorRange + { + int mPc; + int mValue; + QColor mColor; + }; + + int mRange; + int mCount; + int mCurrentCount; + int mValue; + Q3PtrList<ColorRange> mCRanges; +}; + +#endif diff --git a/examples/graphicsview/portedasteroids/main.cpp b/examples/graphicsview/portedasteroids/main.cpp new file mode 100644 index 0000000..69b5fd5 --- /dev/null +++ b/examples/graphicsview/portedasteroids/main.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** 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 <QtGui> + +#include "toplevel.h" + +int main(int argc, char **argv) +{ + Q_INIT_RESOURCE(portedasteroids); + + QApplication app(argc, argv); + + qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); + + KAstTopLevel topLevel; + topLevel.setWindowTitle("Ported Asteroids Game"); + topLevel.show(); + + app.setQuitOnLastWindowClosed(true); + return app.exec(); +} diff --git a/examples/graphicsview/portedasteroids/portedasteroids.pro b/examples/graphicsview/portedasteroids/portedasteroids.pro new file mode 100644 index 0000000..1452e91 --- /dev/null +++ b/examples/graphicsview/portedasteroids/portedasteroids.pro @@ -0,0 +1,19 @@ +TEMPLATE = app +INCLUDEPATH += . + +# Input +HEADERS += ledmeter.h sprites.h toplevel.h view.h +SOURCES += ledmeter.cpp main.cpp toplevel.cpp view.cpp +#The following line was inserted by qt3to4 +QT += qt3support + +HEADERS += animateditem.h +SOURCES += animateditem.cpp + +RESOURCES += portedasteroids.qrc + +# install +target.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/portedasteroids +sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS portedasteroids.pro bg.png sounds sprites +sources.path = $$[QT_INSTALL_EXAMPLES]/graphicsview/portedasteroids +INSTALLS += target sources diff --git a/examples/graphicsview/portedasteroids/portedasteroids.qrc b/examples/graphicsview/portedasteroids/portedasteroids.qrc new file mode 100644 index 0000000..1780828 --- /dev/null +++ b/examples/graphicsview/portedasteroids/portedasteroids.qrc @@ -0,0 +1,163 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/trolltech/examples/graphicsview/portedasteroids"> +<file>bg.png</file> +<file>sprites/bits/bits0000.png</file> +<file>sprites/bits/bits0001.png</file> +<file>sprites/bits/bits0002.png</file> +<file>sprites/bits/bits0003.png</file> +<file>sprites/bits/bits0004.png</file> +<file>sprites/bits/bits0005.png</file> +<file>sprites/bits/bits0006.png</file> +<file>sprites/bits/bits0007.png</file> +<file>sprites/bits/bits0008.png</file> +<file>sprites/bits/bits0009.png</file> +<file>sprites/bits/bits0010.png</file> +<file>sprites/bits/bits0011.png</file> +<file>sprites/bits/bits0012.png</file> +<file>sprites/bits/bits0013.png</file> +<file>sprites/bits/bits0014.png</file> +<file>sprites/bits/bits0015.png</file> +<file>sprites/ship/ship0000.png</file> +<file>sprites/ship/ship0001.png</file> +<file>sprites/ship/ship0002.png</file> +<file>sprites/ship/ship0003.png</file> +<file>sprites/ship/ship0004.png</file> +<file>sprites/ship/ship0005.png</file> +<file>sprites/ship/ship0006.png</file> +<file>sprites/ship/ship0007.png</file> +<file>sprites/ship/ship0008.png</file> +<file>sprites/ship/ship0009.png</file> +<file>sprites/ship/ship0010.png</file> +<file>sprites/ship/ship0011.png</file> +<file>sprites/ship/ship0012.png</file> +<file>sprites/ship/ship0013.png</file> +<file>sprites/ship/ship0014.png</file> +<file>sprites/ship/ship0015.png</file> +<file>sprites/ship/ship0016.png</file> +<file>sprites/ship/ship0017.png</file> +<file>sprites/ship/ship0018.png</file> +<file>sprites/ship/ship0019.png</file> +<file>sprites/ship/ship0020.png</file> +<file>sprites/ship/ship0021.png</file> +<file>sprites/ship/ship0022.png</file> +<file>sprites/ship/ship0023.png</file> +<file>sprites/ship/ship0024.png</file> +<file>sprites/ship/ship0025.png</file> +<file>sprites/ship/ship0026.png</file> +<file>sprites/ship/ship0027.png</file> +<file>sprites/ship/ship0028.png</file> +<file>sprites/ship/ship0029.png</file> +<file>sprites/ship/ship0030.png</file> +<file>sprites/ship/ship0031.png</file> +<file>sprites/rock1/rock10016.png</file> +<file>sprites/rock1/rock10017.png</file> +<file>sprites/rock1/rock10018.png</file> +<file>sprites/rock1/rock10019.png</file> +<file>sprites/rock1/rock10020.png</file> +<file>sprites/rock1/rock10021.png</file> +<file>sprites/rock1/rock10022.png</file> +<file>sprites/rock1/rock10023.png</file> +<file>sprites/rock1/rock10024.png</file> +<file>sprites/rock1/rock10025.png</file> +<file>sprites/rock1/rock10026.png</file> +<file>sprites/rock1/rock10027.png</file> +<file>sprites/rock1/rock10028.png</file> +<file>sprites/rock1/rock10029.png</file> +<file>sprites/rock1/rock10030.png</file> +<file>sprites/rock1/rock10031.png</file> +<file>sprites/rock1/rock10000.png</file> +<file>sprites/rock1/rock10001.png</file> +<file>sprites/rock1/rock10002.png</file> +<file>sprites/rock1/rock10003.png</file> +<file>sprites/rock1/rock10004.png</file> +<file>sprites/rock1/rock10005.png</file> +<file>sprites/rock1/rock10006.png</file> +<file>sprites/rock1/rock10007.png</file> +<file>sprites/rock1/rock10008.png</file> +<file>sprites/rock1/rock10009.png</file> +<file>sprites/rock1/rock10010.png</file> +<file>sprites/rock1/rock10011.png</file> +<file>sprites/rock1/rock10012.png</file> +<file>sprites/rock1/rock10013.png</file> +<file>sprites/rock1/rock10014.png</file> +<file>sprites/rock1/rock10015.png</file> +<file>sprites/rock2/rock20000.png</file> +<file>sprites/rock2/rock20001.png</file> +<file>sprites/rock2/rock20002.png</file> +<file>sprites/rock2/rock20003.png</file> +<file>sprites/rock2/rock20004.png</file> +<file>sprites/rock2/rock20005.png</file> +<file>sprites/rock2/rock20006.png</file> +<file>sprites/rock2/rock20007.png</file> +<file>sprites/rock2/rock20008.png</file> +<file>sprites/rock2/rock20009.png</file> +<file>sprites/rock2/rock20010.png</file> +<file>sprites/rock2/rock20011.png</file> +<file>sprites/rock2/rock20012.png</file> +<file>sprites/rock2/rock20013.png</file> +<file>sprites/rock2/rock20014.png</file> +<file>sprites/rock2/rock20015.png</file> +<file>sprites/rock2/rock20016.png</file> +<file>sprites/rock2/rock20017.png</file> +<file>sprites/rock2/rock20018.png</file> +<file>sprites/rock2/rock20019.png</file> +<file>sprites/rock2/rock20020.png</file> +<file>sprites/rock2/rock20021.png</file> +<file>sprites/rock2/rock20022.png</file> +<file>sprites/rock2/rock20023.png</file> +<file>sprites/rock2/rock20024.png</file> +<file>sprites/rock2/rock20025.png</file> +<file>sprites/rock2/rock20026.png</file> +<file>sprites/rock2/rock20027.png</file> +<file>sprites/rock2/rock20028.png</file> +<file>sprites/rock2/rock20029.png</file> +<file>sprites/rock2/rock20030.png</file> +<file>sprites/rock2/rock20031.png</file> +<file>sprites/rock3/rock30000.png</file> +<file>sprites/rock3/rock30001.png</file> +<file>sprites/rock3/rock30002.png</file> +<file>sprites/rock3/rock30003.png</file> +<file>sprites/rock3/rock30004.png</file> +<file>sprites/rock3/rock30005.png</file> +<file>sprites/rock3/rock30006.png</file> +<file>sprites/rock3/rock30007.png</file> +<file>sprites/rock3/rock30008.png</file> +<file>sprites/rock3/rock30009.png</file> +<file>sprites/rock3/rock30010.png</file> +<file>sprites/rock3/rock30011.png</file> +<file>sprites/rock3/rock30012.png</file> +<file>sprites/rock3/rock30013.png</file> +<file>sprites/rock3/rock30014.png</file> +<file>sprites/rock3/rock30015.png</file> +<file>sprites/rock3/rock30016.png</file> +<file>sprites/rock3/rock30017.png</file> +<file>sprites/rock3/rock30018.png</file> +<file>sprites/rock3/rock30019.png</file> +<file>sprites/rock3/rock30020.png</file> +<file>sprites/rock3/rock30021.png</file> +<file>sprites/rock3/rock30022.png</file> +<file>sprites/rock3/rock30023.png</file> +<file>sprites/rock3/rock30024.png</file> +<file>sprites/rock3/rock30025.png</file> +<file>sprites/rock3/rock30026.png</file> +<file>sprites/rock3/rock30027.png</file> +<file>sprites/rock3/rock30028.png</file> +<file>sprites/rock3/rock30029.png</file> +<file>sprites/rock3/rock30030.png</file> +<file>sprites/rock3/rock30031.png</file> +<file>sprites/missile/missile.png</file> +<file>sprites/exhaust/exhaust.png</file> +<file>sprites/powerups/shield.png</file> +<file>sprites/powerups/shoot.png</file> +<file>sprites/powerups/teleport.png</file> +<file>sprites/powerups/brake.png</file> +<file>sprites/powerups/energy.png</file> +<file>sprites/shield/shield0000.png</file> +<file>sprites/shield/shield0001.png</file> +<file>sprites/shield/shield0002.png</file> +<file>sprites/shield/shield0003.png</file> +<file>sprites/shield/shield0004.png</file> +<file>sprites/shield/shield0005.png</file> +<file>sprites/shield/shield0006.png</file> +</qresource> +</RCC> diff --git a/examples/graphicsview/portedasteroids/sounds/Explosion.wav b/examples/graphicsview/portedasteroids/sounds/Explosion.wav Binary files differnew file mode 100644 index 0000000..7b140b1 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sounds/Explosion.wav diff --git a/examples/graphicsview/portedasteroids/sprites.h b/examples/graphicsview/portedasteroids/sprites.h new file mode 100644 index 0000000..1483d68 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites.h @@ -0,0 +1,170 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +/* + * KAsteroids - Copyright (c) Martin R. Jones 1997 + * + * Part of the KDE project + */ + +#ifndef __SPRITES_H__ +#define __SPRITES_H__ + +#include "animateditem.h" + +#define ID_ROCK_LARGE 1024 +#define ID_ROCK_MEDIUM 1025 +#define ID_ROCK_SMALL 1026 + +#define ID_MISSILE 1030 + +#define ID_BIT 1040 +#define ID_EXHAUST 1041 + +#define ID_ENERGY_POWERUP 1310 +#define ID_TELEPORT_POWERUP 1311 +#define ID_BRAKE_POWERUP 1312 +#define ID_SHIELD_POWERUP 1313 +#define ID_SHOOT_POWERUP 1314 + +#define ID_SHIP 1350 +#define ID_SHIELD 1351 + +#define MAX_SHIELD_AGE 350 +#define MAX_POWERUP_AGE 500 +#define MAX_MISSILE_AGE 40 + +class KMissile : public AnimatedPixmapItem +{ +public: + KMissile( const QList<QPixmap> &s, QGraphicsScene *c ) : AnimatedPixmapItem( s, c ) + { myAge = 0; } + + virtual int type() const { return ID_MISSILE; } + + void growOlder() { myAge++; } + bool expired() { return myAge > MAX_MISSILE_AGE; } + +private: + int myAge; +}; + +class KBit : public AnimatedPixmapItem +{ +public: + KBit( const QList<QPixmap> &s, QGraphicsScene *c ) : AnimatedPixmapItem( s, c ) + { death = 7; } + + virtual int type() const { return ID_BIT; } + + void setDeath( int d ) { death = d; } + void growOlder() { death--; } + bool expired() { return death <= 0; } + +private: + int death; +}; + +class KExhaust : public AnimatedPixmapItem +{ +public: + KExhaust( const QList<QPixmap> &s, QGraphicsScene *c ) : AnimatedPixmapItem( s, c ) + { death = 1; } + + virtual int type() const { return ID_EXHAUST; } + + void setDeath( int d ) { death = d; } + void growOlder() { death--; } + bool expired() { return death <= 0; } + +private: + int death; +}; + +class KPowerup : public AnimatedPixmapItem +{ +public: + KPowerup( const QList<QPixmap> &s, QGraphicsScene *c, int t ) : AnimatedPixmapItem( s, c ), + myAge( 0 ), _type(t) { } + + virtual int type() const { return _type; } + + void growOlder() { myAge++; } + bool expired() const { return myAge > MAX_POWERUP_AGE; } + +protected: + int myAge; + int _type; +}; + +class KRock : public AnimatedPixmapItem +{ +public: + KRock (const QList<QPixmap> &s, QGraphicsScene *c, int t, int sk, int st) : AnimatedPixmapItem( s, c ) + { _type = t; skip = cskip = sk; step = st; } + + void nextFrame() + { + if (cskip-- <= 0) { + setFrame( (frame()+step+frameCount())%frameCount() ); + cskip = QABS(skip); + } + } + + virtual int type() const { return _type; } + +private: + int _type; + int skip; + int cskip; + int step; +}; + +class KShield : public AnimatedPixmapItem +{ +public: + KShield( QList<QPixmap> &s, QGraphicsScene *c ) + : AnimatedPixmapItem( s, c ) {} + + virtual int type() const { return ID_SHIELD; } +}; + +#endif diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits.ini b/examples/graphicsview/portedasteroids/sprites/bits/bits.ini new file mode 100644 index 0000000..cb2976f --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits.ini @@ -0,0 +1,9 @@ +Cyclic_Animation=On +Width=12 +Height=12 +Final_frame=16 ;; NR_ROTS +Antialias=On +Output_Alpha=On +Output_to_File=On +Output_File_Type=n +Input_File_Name=bits.pov diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits.pov b/examples/graphicsview/portedasteroids/sprites/bits/bits.pov new file mode 100644 index 0000000..9be7ccb --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits.pov @@ -0,0 +1,31 @@ + +#version 3.0 +global_settings { assumed_gamma 2.0 } + +#include "colors.inc" +#include "textures.inc" +#include "metals.inc" + +camera { + location <15, -15, -100> + look_at <0, 0, 0> +} + +light_source { <50, 50, -50> colour White } +light_source { <0, 0, -50> colour White } + +prism { + linear_sweep + linear_spline + 0, + 0.2, + 5, + <2, 0>, <0, 2>, <-1, 1>, <0, -3>, <2, 0> + texture { T_Silver_2A } + + rotate <360*clock, 50, 30> + scale <20, 20, 20> +} + + + diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0000.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0000.png Binary files differnew file mode 100644 index 0000000..5ec9d02 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0000.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0001.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0001.png Binary files differnew file mode 100644 index 0000000..07b4012 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0001.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0002.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0002.png Binary files differnew file mode 100644 index 0000000..8333792 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0002.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0003.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0003.png Binary files differnew file mode 100644 index 0000000..9f1fc02 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0003.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0004.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0004.png Binary files differnew file mode 100644 index 0000000..eb1cc09 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0004.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0005.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0005.png Binary files differnew file mode 100644 index 0000000..149be63 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0005.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0006.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0006.png Binary files differnew file mode 100644 index 0000000..4ac75c8 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0006.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0007.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0007.png Binary files differnew file mode 100644 index 0000000..907241d --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0007.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0008.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0008.png Binary files differnew file mode 100644 index 0000000..1533268 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0008.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0009.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0009.png Binary files differnew file mode 100644 index 0000000..05402ba --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0009.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0010.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0010.png Binary files differnew file mode 100644 index 0000000..ca4f229 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0010.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0011.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0011.png Binary files differnew file mode 100644 index 0000000..91913c0 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0011.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0012.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0012.png Binary files differnew file mode 100644 index 0000000..e55d439 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0012.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0013.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0013.png Binary files differnew file mode 100644 index 0000000..9c73436 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0013.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0014.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0014.png Binary files differnew file mode 100644 index 0000000..f0463a2 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0014.png diff --git a/examples/graphicsview/portedasteroids/sprites/bits/bits0015.png b/examples/graphicsview/portedasteroids/sprites/bits/bits0015.png Binary files differnew file mode 100644 index 0000000..bce35aa --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/bits/bits0015.png diff --git a/examples/graphicsview/portedasteroids/sprites/exhaust/exhaust.png b/examples/graphicsview/portedasteroids/sprites/exhaust/exhaust.png Binary files differnew file mode 100644 index 0000000..1d9bc33 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/exhaust/exhaust.png diff --git a/examples/graphicsview/portedasteroids/sprites/missile/missile.png b/examples/graphicsview/portedasteroids/sprites/missile/missile.png Binary files differnew file mode 100644 index 0000000..f1a83b2 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/missile/missile.png diff --git a/examples/graphicsview/portedasteroids/sprites/powerups/brake.png b/examples/graphicsview/portedasteroids/sprites/powerups/brake.png Binary files differnew file mode 100644 index 0000000..5f65a11 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/powerups/brake.png diff --git a/examples/graphicsview/portedasteroids/sprites/powerups/energy.png b/examples/graphicsview/portedasteroids/sprites/powerups/energy.png Binary files differnew file mode 100644 index 0000000..4b40074 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/powerups/energy.png diff --git a/examples/graphicsview/portedasteroids/sprites/powerups/shield.png b/examples/graphicsview/portedasteroids/sprites/powerups/shield.png Binary files differnew file mode 100644 index 0000000..6ac6868 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/powerups/shield.png diff --git a/examples/graphicsview/portedasteroids/sprites/powerups/shoot.png b/examples/graphicsview/portedasteroids/sprites/powerups/shoot.png Binary files differnew file mode 100644 index 0000000..5e5bf08 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/powerups/shoot.png diff --git a/examples/graphicsview/portedasteroids/sprites/powerups/teleport.png b/examples/graphicsview/portedasteroids/sprites/powerups/teleport.png Binary files differnew file mode 100644 index 0000000..009c229 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/powerups/teleport.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock1.ini b/examples/graphicsview/portedasteroids/sprites/rock1/rock1.ini new file mode 100644 index 0000000..e42fc76 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock1.ini @@ -0,0 +1,9 @@ +Cyclic_Animation=On +Width=48 +Height=48 +Final_frame=32 ;; NR_ROTS +Antialias=On +Output_Alpha=On +Output_to_File=On +Output_File_Type=n +Input_File_Name=rock1.pov diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock1.pov b/examples/graphicsview/portedasteroids/sprites/rock1/rock1.pov new file mode 100644 index 0000000..58298c0 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock1.pov @@ -0,0 +1,26 @@ +#include "colors.inc" +#include "shapes.inc" +#include "textures.inc" +// #include "stones.inc" + +camera { + location <2,2,-6> + up <0, 1, 0> +// right <4/3, 0, 0> + look_at <0,0,0> +} + +object { light_source { <10, 5, -5> color red 1.1 green 1.1 blue 1.0 } } + +#declare Rock = +mesh { + #include "rock.inc" /* collection of triangle or smooth_triangle data */ +} + +object { + Rock + texture { pigment {White} } + scale 1.9 + rotate <60, 45, 360*clock> +} + diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10000.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10000.png Binary files differnew file mode 100644 index 0000000..5fe70ef --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10000.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10001.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10001.png Binary files differnew file mode 100644 index 0000000..ea66dac --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10001.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10002.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10002.png Binary files differnew file mode 100644 index 0000000..cb55ed0 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10002.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10003.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10003.png Binary files differnew file mode 100644 index 0000000..f82934c --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10003.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10004.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10004.png Binary files differnew file mode 100644 index 0000000..04efc2b --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10004.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10005.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10005.png Binary files differnew file mode 100644 index 0000000..b9c0d03 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10005.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10006.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10006.png Binary files differnew file mode 100644 index 0000000..7f91267 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10006.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10007.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10007.png Binary files differnew file mode 100644 index 0000000..b28f219 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10007.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10008.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10008.png Binary files differnew file mode 100644 index 0000000..0153d4a --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10008.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10009.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10009.png Binary files differnew file mode 100644 index 0000000..c04d827 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10009.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10010.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10010.png Binary files differnew file mode 100644 index 0000000..c7d3c40 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10010.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10011.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10011.png Binary files differnew file mode 100644 index 0000000..233dfce --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10011.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10012.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10012.png Binary files differnew file mode 100644 index 0000000..ec7b5ba --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10012.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10013.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10013.png Binary files differnew file mode 100644 index 0000000..22eac3a --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10013.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10014.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10014.png Binary files differnew file mode 100644 index 0000000..ad1503d --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10014.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10015.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10015.png Binary files differnew file mode 100644 index 0000000..cec22e2 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10015.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10016.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10016.png Binary files differnew file mode 100644 index 0000000..c7a96cb --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10016.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10017.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10017.png Binary files differnew file mode 100644 index 0000000..c8310bd --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10017.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10018.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10018.png Binary files differnew file mode 100644 index 0000000..b8d436b --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10018.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10019.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10019.png Binary files differnew file mode 100644 index 0000000..e5d0799 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10019.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10020.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10020.png Binary files differnew file mode 100644 index 0000000..440f8d0 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10020.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10021.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10021.png Binary files differnew file mode 100644 index 0000000..de3d54d --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10021.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10022.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10022.png Binary files differnew file mode 100644 index 0000000..698056d --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10022.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10023.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10023.png Binary files differnew file mode 100644 index 0000000..4e6ba04 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10023.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10024.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10024.png Binary files differnew file mode 100644 index 0000000..3b42850 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10024.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10025.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10025.png Binary files differnew file mode 100644 index 0000000..6813936 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10025.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10026.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10026.png Binary files differnew file mode 100644 index 0000000..4a2b171 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10026.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10027.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10027.png Binary files differnew file mode 100644 index 0000000..30448fb --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10027.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10028.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10028.png Binary files differnew file mode 100644 index 0000000..43ca1a9 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10028.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10029.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10029.png Binary files differnew file mode 100644 index 0000000..9d7e888 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10029.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10030.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10030.png Binary files differnew file mode 100644 index 0000000..39b2ad2 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10030.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock1/rock10031.png b/examples/graphicsview/portedasteroids/sprites/rock1/rock10031.png Binary files differnew file mode 100644 index 0000000..257ec7b --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock1/rock10031.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock2.ini b/examples/graphicsview/portedasteroids/sprites/rock2/rock2.ini new file mode 100644 index 0000000..d50e6fa --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock2.ini @@ -0,0 +1,9 @@ +Cyclic_Animation=On +Width=32 +Height=32 +Final_frame=32 ;; NR_ROTS +Antialias=On +Output_Alpha=On +Output_to_File=On +Output_File_Type=n +Input_File_Name=rock2.pov diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock2.pov b/examples/graphicsview/portedasteroids/sprites/rock2/rock2.pov new file mode 100644 index 0000000..2f37a20 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock2.pov @@ -0,0 +1,26 @@ +#include "colors.inc" +#include "shapes.inc" +#include "textures.inc" +// #include "stones.inc" + +camera { + location <2,2,-6> + up <0, 1, 0> +// right <4/3, 0, 0> + look_at <0,0,0> +} + +object { light_source { <10, 5, -5> color red 1.1 green 1.1 blue 1.0 } } + +#declare Rock = +mesh { + #include "rock.inc" /* collection of triangle or smooth_triangle data */ +} + +object { + Rock + texture { pigment {White} } + scale 1.9 + rotate <60, 30, 360*clock> +} + diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20000.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20000.png Binary files differnew file mode 100644 index 0000000..5cb52bb --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20000.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20001.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20001.png Binary files differnew file mode 100644 index 0000000..d765be1 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20001.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20002.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20002.png Binary files differnew file mode 100644 index 0000000..84e2380 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20002.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20003.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20003.png Binary files differnew file mode 100644 index 0000000..39772b8 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20003.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20004.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20004.png Binary files differnew file mode 100644 index 0000000..b983079 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20004.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20005.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20005.png Binary files differnew file mode 100644 index 0000000..70bb4d8 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20005.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20006.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20006.png Binary files differnew file mode 100644 index 0000000..cf5c2f4 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20006.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20007.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20007.png Binary files differnew file mode 100644 index 0000000..479c21d --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20007.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20008.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20008.png Binary files differnew file mode 100644 index 0000000..871abca --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20008.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20009.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20009.png Binary files differnew file mode 100644 index 0000000..bc31fbb --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20009.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20010.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20010.png Binary files differnew file mode 100644 index 0000000..1da9953 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20010.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20011.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20011.png Binary files differnew file mode 100644 index 0000000..d542c6e --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20011.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20012.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20012.png Binary files differnew file mode 100644 index 0000000..d104ff9 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20012.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20013.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20013.png Binary files differnew file mode 100644 index 0000000..e12943d --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20013.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20014.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20014.png Binary files differnew file mode 100644 index 0000000..dc7529c --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20014.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20015.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20015.png Binary files differnew file mode 100644 index 0000000..0b49c2c --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20015.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20016.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20016.png Binary files differnew file mode 100644 index 0000000..adbad98 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20016.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20017.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20017.png Binary files differnew file mode 100644 index 0000000..5a8aeef --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20017.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20018.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20018.png Binary files differnew file mode 100644 index 0000000..11c6af4 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20018.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20019.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20019.png Binary files differnew file mode 100644 index 0000000..026b72b --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20019.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20020.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20020.png Binary files differnew file mode 100644 index 0000000..8bc7e20 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20020.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20021.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20021.png Binary files differnew file mode 100644 index 0000000..e0a7626 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20021.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20022.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20022.png Binary files differnew file mode 100644 index 0000000..5796e12 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20022.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20023.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20023.png Binary files differnew file mode 100644 index 0000000..d2cf0c6 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20023.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20024.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20024.png Binary files differnew file mode 100644 index 0000000..071ce21 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20024.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20025.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20025.png Binary files differnew file mode 100644 index 0000000..ae8101d --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20025.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20026.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20026.png Binary files differnew file mode 100644 index 0000000..f2681d4 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20026.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20027.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20027.png Binary files differnew file mode 100644 index 0000000..e83fd41 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20027.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20028.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20028.png Binary files differnew file mode 100644 index 0000000..5621b4d --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20028.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20029.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20029.png Binary files differnew file mode 100644 index 0000000..aec4a34 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20029.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20030.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20030.png Binary files differnew file mode 100644 index 0000000..89a8f5f --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20030.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock2/rock20031.png b/examples/graphicsview/portedasteroids/sprites/rock2/rock20031.png Binary files differnew file mode 100644 index 0000000..69f5375 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock2/rock20031.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock3.ini b/examples/graphicsview/portedasteroids/sprites/rock3/rock3.ini new file mode 100644 index 0000000..26a3cf9 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock3.ini @@ -0,0 +1,9 @@ +Cyclic_Animation=On +Width=20 +Height=20 +Final_frame=32 ;; NR_ROTS +Antialias=On +Output_Alpha=On +Output_to_File=On +Output_File_Type=n +Input_File_Name=rock3.pov diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock3.pov b/examples/graphicsview/portedasteroids/sprites/rock3/rock3.pov new file mode 100644 index 0000000..2f37a20 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock3.pov @@ -0,0 +1,26 @@ +#include "colors.inc" +#include "shapes.inc" +#include "textures.inc" +// #include "stones.inc" + +camera { + location <2,2,-6> + up <0, 1, 0> +// right <4/3, 0, 0> + look_at <0,0,0> +} + +object { light_source { <10, 5, -5> color red 1.1 green 1.1 blue 1.0 } } + +#declare Rock = +mesh { + #include "rock.inc" /* collection of triangle or smooth_triangle data */ +} + +object { + Rock + texture { pigment {White} } + scale 1.9 + rotate <60, 30, 360*clock> +} + diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30000.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30000.png Binary files differnew file mode 100644 index 0000000..de1205a --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30000.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30001.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30001.png Binary files differnew file mode 100644 index 0000000..12ebc00 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30001.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30002.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30002.png Binary files differnew file mode 100644 index 0000000..ebb899e --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30002.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30003.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30003.png Binary files differnew file mode 100644 index 0000000..1ff7a06 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30003.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30004.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30004.png Binary files differnew file mode 100644 index 0000000..5b505bf --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30004.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30005.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30005.png Binary files differnew file mode 100644 index 0000000..f9680dc --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30005.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30006.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30006.png Binary files differnew file mode 100644 index 0000000..e29746a --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30006.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30007.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30007.png Binary files differnew file mode 100644 index 0000000..f01baa6 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30007.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30008.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30008.png Binary files differnew file mode 100644 index 0000000..cd10711 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30008.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30009.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30009.png Binary files differnew file mode 100644 index 0000000..4f32955 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30009.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30010.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30010.png Binary files differnew file mode 100644 index 0000000..bb61d54 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30010.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30011.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30011.png Binary files differnew file mode 100644 index 0000000..8486e5a --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30011.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30012.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30012.png Binary files differnew file mode 100644 index 0000000..d9ae419 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30012.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30013.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30013.png Binary files differnew file mode 100644 index 0000000..ce69400 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30013.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30014.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30014.png Binary files differnew file mode 100644 index 0000000..981e92c --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30014.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30015.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30015.png Binary files differnew file mode 100644 index 0000000..b8fb00c --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30015.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30016.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30016.png Binary files differnew file mode 100644 index 0000000..72bc42f --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30016.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30017.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30017.png Binary files differnew file mode 100644 index 0000000..c89f358 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30017.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30018.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30018.png Binary files differnew file mode 100644 index 0000000..e1ba724 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30018.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30019.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30019.png Binary files differnew file mode 100644 index 0000000..5f004a7 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30019.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30020.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30020.png Binary files differnew file mode 100644 index 0000000..58009bf --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30020.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30021.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30021.png Binary files differnew file mode 100644 index 0000000..8d9549c --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30021.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30022.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30022.png Binary files differnew file mode 100644 index 0000000..1e8a1c2 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30022.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30023.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30023.png Binary files differnew file mode 100644 index 0000000..9b960d6 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30023.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30024.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30024.png Binary files differnew file mode 100644 index 0000000..6c15f2b --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30024.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30025.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30025.png Binary files differnew file mode 100644 index 0000000..12b05da --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30025.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30026.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30026.png Binary files differnew file mode 100644 index 0000000..16190e9 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30026.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30027.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30027.png Binary files differnew file mode 100644 index 0000000..a862501 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30027.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30028.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30028.png Binary files differnew file mode 100644 index 0000000..e3e0c18 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30028.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30029.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30029.png Binary files differnew file mode 100644 index 0000000..ec70b84 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30029.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30030.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30030.png Binary files differnew file mode 100644 index 0000000..da48df1 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30030.png diff --git a/examples/graphicsview/portedasteroids/sprites/rock3/rock30031.png b/examples/graphicsview/portedasteroids/sprites/rock3/rock30031.png Binary files differnew file mode 100644 index 0000000..c1dc1b9 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/rock3/rock30031.png diff --git a/examples/graphicsview/portedasteroids/sprites/shield/shield0000.png b/examples/graphicsview/portedasteroids/sprites/shield/shield0000.png Binary files differnew file mode 100644 index 0000000..7233254 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/shield/shield0000.png diff --git a/examples/graphicsview/portedasteroids/sprites/shield/shield0001.png b/examples/graphicsview/portedasteroids/sprites/shield/shield0001.png Binary files differnew file mode 100644 index 0000000..2b0bc9d --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/shield/shield0001.png diff --git a/examples/graphicsview/portedasteroids/sprites/shield/shield0002.png b/examples/graphicsview/portedasteroids/sprites/shield/shield0002.png Binary files differnew file mode 100644 index 0000000..cdc0fe3 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/shield/shield0002.png diff --git a/examples/graphicsview/portedasteroids/sprites/shield/shield0003.png b/examples/graphicsview/portedasteroids/sprites/shield/shield0003.png Binary files differnew file mode 100644 index 0000000..979ed5a --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/shield/shield0003.png diff --git a/examples/graphicsview/portedasteroids/sprites/shield/shield0004.png b/examples/graphicsview/portedasteroids/sprites/shield/shield0004.png Binary files differnew file mode 100644 index 0000000..0bb93a2 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/shield/shield0004.png diff --git a/examples/graphicsview/portedasteroids/sprites/shield/shield0005.png b/examples/graphicsview/portedasteroids/sprites/shield/shield0005.png Binary files differnew file mode 100644 index 0000000..32210bd --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/shield/shield0005.png diff --git a/examples/graphicsview/portedasteroids/sprites/shield/shield0006.png b/examples/graphicsview/portedasteroids/sprites/shield/shield0006.png Binary files differnew file mode 100644 index 0000000..76c9920 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/shield/shield0006.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship.ini b/examples/graphicsview/portedasteroids/sprites/ship/ship.ini new file mode 100644 index 0000000..479cc20 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship.ini @@ -0,0 +1,9 @@ +Cyclic_Animation=On +Width=42 +Height=42 +Final_frame=32 ;; NR_ROTS +Antialias=On +Output_Alpha=On +Output_to_File=On +Output_File_Type=n +Input_File_Name=ship.pov diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship.pov b/examples/graphicsview/portedasteroids/sprites/ship/ship.pov new file mode 100644 index 0000000..8f185cd --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship.pov @@ -0,0 +1,128 @@ + +#version 3.0 +global_settings { assumed_gamma 2.0 } + +#include "colors.inc" +#include "textures.inc" +#include "metals.inc" + +camera { + orthographic + up <0, 130, 0> + right <130, 0, 0> + location <0, 0, -130> + look_at <0, 0, 0> +} + +light_source { <50, 25, -25> colour White } +light_source { <0, 0, -100> colour Gray80 } + +#declare ShipColor = color red 1.0 green 1.0 blue 0.9 + +#declare BaseTexture = +texture { + pigment { ShipColor } +} + +#declare Grubby = +texture { + pigment { + bozo + color_map { + [0.0 color rgbt <1, 1, 1, 1>] + [0.8 color rgbt <0.9, 0.9, 0.9, 0.5>] + [1.0 color rgbt <0.8, 0.8, 0.8, 0.5>] + } + turbulence 2.0 + scale 3 + } +} + +#declare ShipTexture = +texture { BaseTexture } +texture { Grubby } + +union { + cone { + <12, 0, 0>, 0.5 + <11, 0, 0>, 1.0 + texture { ShipTexture } + } + cone { + <11, 0, 0>, 1.0 + <8, 0, 0>, 2.0 + texture { ShipTexture } + } + cone { + <8, 0, 0>, 2.0 + <3.5, 0, 0>, 3.8 + texture { ShipTexture } + } + difference { + cone { + <8, 0, -0.01>, 2.0 + <3.5, 0, -0.01>, 3.8 + pigment { color Gray20 } + } + box { + <9, -4.0, -3.7>, + <2, 4.0, 10> + rotate <0, -18, 0> + } + box { + <6.5, -4.0, -8>, + <10, 4.0, 8> + } + box { + <2, -4.0, -8>, + <4.5, 4.0, 8> + } + } + cone { + <3.5, 0, 0>, 3.8 + <2, 0, 0>, 4.0 + texture { ShipTexture } + } + cylinder { + <2, 0, 0>, + <-9, 0, 0>, + 4.0 + texture { ShipTexture } + } + cone { + <-9, 0, 0>, 4.0 + <-10, 0, 0>, 3.5 + texture { ShipTexture } + } + prism { + linear_sweep + linear_spline + 0, + 0.5, + 4, + <7.5, 0>, <-7.5, 10>, <-7.5, -10>, <7.5, 0> + rotate <90, 0, 0> + texture { T_Silver_2A } + texture { ShipTexture } + } + prism { + linear_sweep + linear_spline + -0.5, + 0.5, + 4, + <4, 0>, <-7.5, 5>, <-7.5, -5>, <4, 0> + pigment { color White } + } + cone { + <-12, 0, 0>, 3.0 + <-10, 0, 0>, 2.0 + texture { T_Silver_2A } + pigment { color Gray60 } + } + + rotate <0, 0,-360*clock> + scale <5, 5, 5> +} + + diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0000.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0000.png Binary files differnew file mode 100644 index 0000000..a8f1bb3 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0000.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0001.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0001.png Binary files differnew file mode 100644 index 0000000..861f130 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0001.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0002.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0002.png Binary files differnew file mode 100644 index 0000000..418ced1 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0002.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0003.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0003.png Binary files differnew file mode 100644 index 0000000..50a386b --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0003.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0004.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0004.png Binary files differnew file mode 100644 index 0000000..f2bc0bc --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0004.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0005.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0005.png Binary files differnew file mode 100644 index 0000000..7280485 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0005.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0006.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0006.png Binary files differnew file mode 100644 index 0000000..51d26e9 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0006.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0007.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0007.png Binary files differnew file mode 100644 index 0000000..682c042 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0007.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0008.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0008.png Binary files differnew file mode 100644 index 0000000..003d7fa --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0008.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0009.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0009.png Binary files differnew file mode 100644 index 0000000..538b879 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0009.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0010.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0010.png Binary files differnew file mode 100644 index 0000000..17999cd --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0010.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0011.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0011.png Binary files differnew file mode 100644 index 0000000..1a4bbe9 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0011.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0012.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0012.png Binary files differnew file mode 100644 index 0000000..2523d85 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0012.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0013.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0013.png Binary files differnew file mode 100644 index 0000000..8bd5971 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0013.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0014.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0014.png Binary files differnew file mode 100644 index 0000000..a164ab7 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0014.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0015.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0015.png Binary files differnew file mode 100644 index 0000000..ca8e0b9 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0015.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0016.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0016.png Binary files differnew file mode 100644 index 0000000..cfaf8c4 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0016.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0017.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0017.png Binary files differnew file mode 100644 index 0000000..8049617 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0017.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0018.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0018.png Binary files differnew file mode 100644 index 0000000..4a3421b --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0018.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0019.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0019.png Binary files differnew file mode 100644 index 0000000..786d375 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0019.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0020.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0020.png Binary files differnew file mode 100644 index 0000000..bd4365c --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0020.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0021.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0021.png Binary files differnew file mode 100644 index 0000000..eb358c1 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0021.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0022.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0022.png Binary files differnew file mode 100644 index 0000000..eb865e1 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0022.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0023.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0023.png Binary files differnew file mode 100644 index 0000000..3738ce2 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0023.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0024.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0024.png Binary files differnew file mode 100644 index 0000000..a7c1adc --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0024.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0025.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0025.png Binary files differnew file mode 100644 index 0000000..2ca3aae --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0025.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0026.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0026.png Binary files differnew file mode 100644 index 0000000..4661ca5 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0026.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0027.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0027.png Binary files differnew file mode 100644 index 0000000..f5c9203 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0027.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0028.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0028.png Binary files differnew file mode 100644 index 0000000..08353d4 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0028.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0029.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0029.png Binary files differnew file mode 100644 index 0000000..8685d31 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0029.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0030.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0030.png Binary files differnew file mode 100644 index 0000000..78dd469 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0030.png diff --git a/examples/graphicsview/portedasteroids/sprites/ship/ship0031.png b/examples/graphicsview/portedasteroids/sprites/ship/ship0031.png Binary files differnew file mode 100644 index 0000000..6cd0643 --- /dev/null +++ b/examples/graphicsview/portedasteroids/sprites/ship/ship0031.png diff --git a/examples/graphicsview/portedasteroids/toplevel.cpp b/examples/graphicsview/portedasteroids/toplevel.cpp new file mode 100644 index 0000000..1aecc84 --- /dev/null +++ b/examples/graphicsview/portedasteroids/toplevel.cpp @@ -0,0 +1,543 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +/* + * KAsteroids - Copyright (c) Martin R. Jones 1997 + * + * Part of the KDE project + */ +// --- toplevel.cpp --- +#include <q3accel.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qlcdnumber.h> +#include <qpushbutton.h> + +#include <qapplication.h> +//Added by qt3to4: +#include <Q3HBoxLayout> +#include <QShowEvent> +#include <Q3Frame> +#include <QPixmap> +#include <QHideEvent> +#include <QKeyEvent> +#include <Q3VBoxLayout> + +#include "toplevel.h" +#include "ledmeter.h" + + +#define SB_SCORE 1 +#define SB_LEVEL 2 +#define SB_SHIPS 3 + +struct SLevel +{ + int nrocks; + double rockSpeed; +}; + +#define MAX_LEVELS 16 + +SLevel levels[MAX_LEVELS] = +{ + { 1, 0.4 }, + { 1, 0.6 }, + { 2, 0.5 }, + { 2, 0.7 }, + { 2, 0.8 }, + { 3, 0.6 }, + { 3, 0.7 }, + { 3, 0.8 }, + { 4, 0.6 }, + { 4, 0.7 }, + { 4, 0.8 }, + { 5, 0.7 }, + { 5, 0.8 }, + { 5, 0.9 }, + { 5, 1.0 } +}; + +const char *soundEvents[] = +{ + "ShipDestroyed", + "RockDestroyed", + 0 +}; + +const char *soundDefaults[] = +{ + "Explosion.wav", + "ploop.wav", + 0 +}; + + +KAstTopLevel::KAstTopLevel( QWidget *parent, const char *name ) + : Q3MainWindow( parent, name, 0 ) +{ + QWidget *border = new QWidget( this ); + border->setBackgroundColor( Qt::black ); + setCentralWidget( border ); + + Q3VBoxLayout *borderLayout = new Q3VBoxLayout( border ); + borderLayout->addStretch( 1 ); + + QWidget *mainWin = new QWidget( border ); + mainWin->setFixedSize(640, 480); + borderLayout->addWidget( mainWin, 0, Qt::AlignHCenter ); + + borderLayout->addStretch( 1 ); + + view = new KAsteroidsView( mainWin ); + view->setFocusPolicy( Qt::StrongFocus ); + connect( view, SIGNAL( shipKilled() ), SLOT( slotShipKilled() ) ); + connect( view, SIGNAL( rockHit(int) ), SLOT( slotRockHit(int) ) ); + connect( view, SIGNAL( rocksRemoved() ), SLOT( slotRocksRemoved() ) ); + connect( view, SIGNAL( updateVitals() ), SLOT( slotUpdateVitals() ) ); + + Q3VBoxLayout *vb = new Q3VBoxLayout( mainWin ); + Q3HBoxLayout *hb = new Q3HBoxLayout; + Q3HBoxLayout *hbd = new Q3HBoxLayout; + vb->addLayout( hb ); + + QFont labelFont( "helvetica", 24 ); + QColorGroup grp( Qt::darkGreen, Qt::black, QColor( 128, 128, 128 ), + QColor( 64, 64, 64 ), Qt::black, Qt::darkGreen, Qt::black ); + QPalette pal( grp, grp, grp ); + + mainWin->setPalette( pal ); + + hb->addSpacing( 10 ); + + QLabel *label; + label = new QLabel( tr("Score"), mainWin ); + label->setFont( labelFont ); + label->setPalette( pal ); + label->setFixedWidth( label->sizeHint().width() ); + hb->addWidget( label ); + + scoreLCD = new QLCDNumber( 6, mainWin ); + scoreLCD->setFrameStyle( Q3Frame::NoFrame ); + scoreLCD->setSegmentStyle( QLCDNumber::Flat ); + scoreLCD->setFixedWidth( 150 ); + scoreLCD->setPalette( pal ); + hb->addWidget( scoreLCD ); + hb->addStretch( 10 ); + + label = new QLabel( tr("Level"), mainWin ); + label->setFont( labelFont ); + label->setPalette( pal ); + label->setFixedWidth( label->sizeHint().width() ); + hb->addWidget( label ); + + levelLCD = new QLCDNumber( 2, mainWin ); + levelLCD->setFrameStyle( Q3Frame::NoFrame ); + levelLCD->setSegmentStyle( QLCDNumber::Flat ); + levelLCD->setFixedWidth( 70 ); + levelLCD->setPalette( pal ); + hb->addWidget( levelLCD ); + hb->addStretch( 10 ); + + label = new QLabel( tr("Ships"), mainWin ); + label->setFont( labelFont ); + label->setFixedWidth( label->sizeHint().width() ); + label->setPalette( pal ); + hb->addWidget( label ); + + shipsLCD = new QLCDNumber( 1, mainWin ); + shipsLCD->setFrameStyle( Q3Frame::NoFrame ); + shipsLCD->setSegmentStyle( QLCDNumber::Flat ); + shipsLCD->setFixedWidth( 40 ); + shipsLCD->setPalette( pal ); + hb->addWidget( shipsLCD ); + + hb->addStrut( 30 ); + + vb->addWidget( view, 10 ); + +// -- bottom layout: + vb->addLayout( hbd ); + + QFont smallFont( "helvetica", 14 ); + hbd->addSpacing( 10 ); + + QString sprites_prefix = ":/trolltech/examples/graphicsview/portedasteroids/sprites/"; +/* + label = new QLabel( tr( "T" ), mainWin ); + label->setFont( smallFont ); + label->setFixedWidth( label->sizeHint().width() ); + label->setPalette( pal ); + hbd->addWidget( label ); + + teleportsLCD = new QLCDNumber( 1, mainWin ); + teleportsLCD->setFrameStyle( QFrame::NoFrame ); + teleportsLCD->setSegmentStyle( QLCDNumber::Flat ); + teleportsLCD->setPalette( pal ); + teleportsLCD->setFixedHeight( 20 ); + hbd->addWidget( teleportsLCD ); + + hbd->addSpacing( 10 ); +*/ + QPixmap pm( sprites_prefix + "powerups/brake.png" ); + label = new QLabel( mainWin ); + label->setPixmap( pm ); + label->setFixedWidth( label->sizeHint().width() ); + label->setPalette( pal ); + hbd->addWidget( label ); + + brakesLCD = new QLCDNumber( 1, mainWin ); + brakesLCD->setFrameStyle( Q3Frame::NoFrame ); + brakesLCD->setSegmentStyle( QLCDNumber::Flat ); + brakesLCD->setPalette( pal ); + brakesLCD->setFixedHeight( 20 ); + hbd->addWidget( brakesLCD ); + + hbd->addSpacing( 10 ); + + pm.load( sprites_prefix + "powerups/shield.png" ); + label = new QLabel( mainWin ); + label->setPixmap( pm ); + label->setFixedWidth( label->sizeHint().width() ); + label->setPalette( pal ); + hbd->addWidget( label ); + + shieldLCD = new QLCDNumber( 1, mainWin ); + shieldLCD->setFrameStyle( Q3Frame::NoFrame ); + shieldLCD->setSegmentStyle( QLCDNumber::Flat ); + shieldLCD->setPalette( pal ); + shieldLCD->setFixedHeight( 20 ); + hbd->addWidget( shieldLCD ); + + hbd->addSpacing( 10 ); + + pm.load( sprites_prefix + "powerups/shoot.png" ); + label = new QLabel( mainWin ); + label->setPixmap( pm ); + label->setFixedWidth( label->sizeHint().width() ); + label->setPalette( pal ); + hbd->addWidget( label ); + + shootLCD = new QLCDNumber( 1, mainWin ); + shootLCD->setFrameStyle( Q3Frame::NoFrame ); + shootLCD->setSegmentStyle( QLCDNumber::Flat ); + shootLCD->setPalette( pal ); + shootLCD->setFixedHeight( 20 ); + hbd->addWidget( shootLCD ); + + hbd->addStretch( 1 ); + + label = new QLabel( tr( "Fuel" ), mainWin ); + label->setFont( smallFont ); + label->setFixedWidth( label->sizeHint().width() + 10 ); + label->setPalette( pal ); + hbd->addWidget( label ); + + powerMeter = new KALedMeter( mainWin ); + powerMeter->setFrameStyle( Q3Frame::Box | Q3Frame::Plain ); + powerMeter->setRange( MAX_POWER_LEVEL ); + powerMeter->addColorRange( 10, Qt::darkRed ); + powerMeter->addColorRange( 20, QColor(160, 96, 0) ); + powerMeter->addColorRange( 70, Qt::darkGreen ); + powerMeter->setCount( 40 ); + powerMeter->setPalette( pal ); + powerMeter->setFixedSize( 200, 12 ); + hbd->addWidget( powerMeter ); + + shipsRemain = 3; + showHiscores = FALSE; + + actions.insert( Qt::Key_Up, Thrust ); + actions.insert( Qt::Key_Left, RotateLeft ); + actions.insert( Qt::Key_Right, RotateRight ); + actions.insert( Qt::Key_Space, Shoot ); + actions.insert( Qt::Key_Z, Teleport ); + actions.insert( Qt::Key_X, Brake ); + actions.insert( Qt::Key_S, Shield ); + actions.insert( Qt::Key_P, Pause ); + actions.insert( Qt::Key_L, Launch ); + actions.insert( Qt::Key_N, NewGame ); + + view->showText( tr( "Press N to start playing" ), Qt::yellow ); +} + +KAstTopLevel::~KAstTopLevel() +{ +} + +void KAstTopLevel::playSound( const char * ) +{ +} + +void KAstTopLevel::keyPressEvent( QKeyEvent *event ) +{ + if ( event->isAutoRepeat() || !actions.contains( event->key() ) ) + { + event->ignore(); + return; + } + + Action a = actions[ event->key() ]; + + switch ( a ) + { + case RotateLeft: + view->rotateLeft( TRUE ); + break; + + case RotateRight: + view->rotateRight( TRUE ); + break; + + case Thrust: + view->thrust( TRUE ); + break; + + case Shoot: + view->shoot( TRUE ); + break; + + case Shield: + view->setShield( TRUE ); + break; + + case Teleport: + view->teleport( TRUE ); + break; + + case Brake: + view->brake( TRUE ); + break; + + default: + event->ignore(); + return; + } + event->accept(); +} + +void KAstTopLevel::keyReleaseEvent( QKeyEvent *event ) +{ + if ( event->isAutoRepeat() || !actions.contains( event->key() ) ) + { + event->ignore(); + return; + } + + Action a = actions[ event->key() ]; + + switch ( a ) + { + case RotateLeft: + view->rotateLeft( FALSE ); + break; + + case RotateRight: + view->rotateRight( FALSE ); + break; + + case Thrust: + view->thrust( FALSE ); + break; + + case Shoot: + view->shoot( FALSE ); + break; + + case Brake: + view->brake( FALSE ); + break; + + case Shield: + view->setShield( FALSE ); + break; + + case Teleport: + view->teleport( FALSE ); + break; + + case Launch: + if ( waitShip ) + { + view->newShip(); + waitShip = FALSE; + view->hideText(); + } + else + { + event->ignore(); + return; + } + break; + + case NewGame: + slotNewGame(); + break; +/* + case Pause: + { + view->pause( TRUE ); + QMessageBox::information( this, + tr("KAsteroids is paused"), + tr("Paused") ); + view->pause( FALSE ); + } + break; +*/ + default: + event->ignore(); + return; + } + + event->accept(); +} + +void KAstTopLevel::showEvent( QShowEvent *e ) +{ + Q3MainWindow::showEvent( e ); + view->pause( FALSE ); + view->setFocus(); +} + +void KAstTopLevel::hideEvent( QHideEvent *e ) +{ + Q3MainWindow::hideEvent( e ); + view->pause( TRUE ); +} + +void KAstTopLevel::slotNewGame() +{ + score = 0; + shipsRemain = SB_SHIPS; + scoreLCD->display( 0 ); + level = 0; + levelLCD->display( level+1 ); + shipsLCD->display( shipsRemain-1 ); + view->newGame(); + view->setRockSpeed( levels[0].rockSpeed ); + view->addRocks( levels[0].nrocks ); +// view->showText( tr( "Press L to launch." ), yellow ); + view->newShip(); + waitShip = FALSE; + view->hideText(); + isPaused = FALSE; +} + +void KAstTopLevel::slotShipKilled() +{ + shipsRemain--; + shipsLCD->display( shipsRemain-1 ); + + playSound( "ShipDestroyed" ); + + if ( shipsRemain ) + { + waitShip = TRUE; + view->showText( tr( "Ship Destroyed. Press L to launch."), Qt::yellow ); + } + else + { + view->showText( tr("Game Over!"), Qt::red ); + view->endGame(); + doStats(); +// highscore->addEntry( score, level, showHiscores ); + } +} + +void KAstTopLevel::slotRockHit( int size ) +{ + switch ( size ) + { + case 0: + score += 10; + break; + + case 1: + score += 20; + break; + + default: + score += 40; + } + + playSound( "RockDestroyed" ); + + scoreLCD->display( score ); +} + +void KAstTopLevel::slotRocksRemoved() +{ + level++; + + if ( level >= MAX_LEVELS ) + level = MAX_LEVELS - 1; + + view->setRockSpeed( levels[level-1].rockSpeed ); + view->addRocks( levels[level-1].nrocks ); + + levelLCD->display( level+1 ); +} + +void KAstTopLevel::doStats() +{ + QString r( "0.00" ); + if ( view->shots() ) + r = QString::number( (double)view->hits() / view->shots() * 100.0, + 'g', 2 ); + +/* multi-line text broken in Qt 3 + QString s = tr( "Game Over\n\nShots fired:\t%1\n Hit:\t%2\n Missed:\t%3\nHit ratio:\t%4 %\n\nPress N for a new game" ) + .arg(view->shots()).arg(view->hits()) + .arg(view->shots() - view->hits()) + .arg(r); +*/ + + view->showText( "Game Over. Press N for a new game.", Qt::yellow, FALSE ); +} + +void KAstTopLevel::slotUpdateVitals() +{ + brakesLCD->display( view->brakeCount() ); + shieldLCD->display( view->shieldCount() ); + shootLCD->display( view->shootCount() ); +// teleportsLCD->display( view->teleportCount() ); + powerMeter->setValue( view->power() ); +} diff --git a/examples/graphicsview/portedasteroids/toplevel.h b/examples/graphicsview/portedasteroids/toplevel.h new file mode 100644 index 0000000..67781da --- /dev/null +++ b/examples/graphicsview/portedasteroids/toplevel.h @@ -0,0 +1,126 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +/* + * KAsteroids - Copyright (c) Martin R. Jones 1997 + * + * Part of the KDE project + */ + +#ifndef __KAST_TOPLEVEL_H__ +#define __KAST_TOPLEVEL_H__ + +#include <q3mainwindow.h> +#include <q3dict.h> +#include <qmap.h> +//Added by qt3to4: +#include <QShowEvent> +#include <QHideEvent> +#include <QKeyEvent> + +#include "view.h" + + +class KALedMeter; +QT_BEGIN_NAMESPACE +class QLCDNumber; +QT_END_NAMESPACE + +class KAstTopLevel : public Q3MainWindow +{ + Q_OBJECT +public: + KAstTopLevel( QWidget *parent=0, const char *name=0 ); + virtual ~KAstTopLevel(); + +private: + void playSound( const char *snd ); + void readSoundMapping(); + void doStats(); + +protected: + virtual void showEvent( QShowEvent * ); + virtual void hideEvent( QHideEvent * ); + virtual void keyPressEvent( QKeyEvent *event ); + virtual void keyReleaseEvent( QKeyEvent *event ); + +private slots: + void slotNewGame(); + + void slotShipKilled(); + void slotRockHit( int size ); + void slotRocksRemoved(); + + void slotUpdateVitals(); + +private: + KAsteroidsView *view; + QLCDNumber *scoreLCD; + QLCDNumber *levelLCD; + QLCDNumber *shipsLCD; + + QLCDNumber *teleportsLCD; +// QLCDNumber *bombsLCD; + QLCDNumber *brakesLCD; + QLCDNumber *shieldLCD; + QLCDNumber *shootLCD; + KALedMeter *powerMeter; + + bool sound; + Q3Dict<QString> soundDict; + + // waiting for user to press Enter to launch a ship + bool waitShip; + bool isPaused; + + int shipsRemain; + int score; + int level; + bool showHiscores; + + enum Action { Launch, Thrust, RotateLeft, RotateRight, Shoot, Teleport, + Brake, Shield, Pause, NewGame }; + + QMap<int,Action> actions; +}; + +#endif + diff --git a/examples/graphicsview/portedasteroids/view.cpp b/examples/graphicsview/portedasteroids/view.cpp new file mode 100644 index 0000000..fc6956b --- /dev/null +++ b/examples/graphicsview/portedasteroids/view.cpp @@ -0,0 +1,967 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +/* + * KAsteroids - Copyright (c) Martin R. Jones 1997 + * + * Part of the KDE project + */ + +#include <stdlib.h> +#include <math.h> +#include <qapplication.h> +#include <qnamespace.h> +#include <q3accel.h> +#include <qmessagebox.h> +#include <q3scrollview.h> +#include <qdir.h> +#include <QGraphicsItem> +//Added by qt3to4: +#include <QTimerEvent> +#include <QPixmap> +#include <QResizeEvent> +#include <QShowEvent> + +#include "view.h" + +#define IMG_BACKGROUND ":/trolltech/examples/graphicsview/portedasteroids/bg.png" + +#define REFRESH_DELAY 33 +#define SHIP_SPEED 0.3 +#define MISSILE_SPEED 10.0 +#define SHIP_STEPS 64 +#define ROTATE_RATE 2 +#define SHIELD_ON_COST 1 +#define SHIELD_HIT_COST 30 +#define BRAKE_ON_COST 4 + +#define MAX_ROCK_SPEED 2.5 +#define MAX_POWERUP_SPEED 1.5 +#define MAX_SHIP_SPEED 12 +#define MAX_BRAKES 5 +#define MAX_SHIELDS 5 +#define MAX_FIREPOWER 5 + +#define TEXT_SPEED 4 + +#define PI_X_2 6.283185307 +#ifndef M_PI +#define M_PI 3.141592654 +#endif + +static struct +{ + int id; + const char *path; + int frames; +} +kas_animations [] = +{ + { ID_ROCK_LARGE, "rock1/rock1%1.png", 32 }, + { ID_ROCK_MEDIUM, "rock2/rock2%1.png", 32 }, + { ID_ROCK_SMALL, "rock3/rock3%1.png", 32 }, + { ID_SHIP, "ship/ship%1.png", 32 }, + { ID_MISSILE, "missile/missile.png", 1 }, + { ID_BIT, "bits/bits%1.png", 16 }, + { ID_EXHAUST, "exhaust/exhaust.png", 1 }, + { ID_ENERGY_POWERUP, "powerups/energy.png", 1 }, +// { ID_TELEPORT_POWERUP, "powerups/teleport%1.png", 12 }, + { ID_BRAKE_POWERUP, "powerups/brake.png", 1 }, + { ID_SHIELD_POWERUP, "powerups/shield.png", 1 }, + { ID_SHOOT_POWERUP, "powerups/shoot.png", 1 }, + { ID_SHIELD, "shield/shield%1.png", 6 }, + { 0, 0, 0 } +}; + +KAsteroidsView::KAsteroidsView( QWidget *parent, const char *name ) + : QWidget( parent, name ), + field(0, 0, 640, 440), + view(&field,this) +{ + view.setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); + view.setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); + view.setCacheMode(QGraphicsView::CacheBackground); + view.setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); + view.setOptimizationFlags(QGraphicsView::DontClipPainter + | QGraphicsView::DontSavePainterState + | QGraphicsView::DontAdjustForAntialiasing); + view.viewport()->setFocusProxy( this ); + rocks.setAutoDelete( TRUE ); + missiles.setAutoDelete( TRUE ); + bits.setAutoDelete( TRUE ); + powerups.setAutoDelete( TRUE ); + exhaust.setAutoDelete( TRUE ); + + QPixmap pm( IMG_BACKGROUND ); + field.setBackgroundBrush( pm ); + + textSprite = new QGraphicsTextItem( 0, &field ); + QFont font( "helvetica", 18 ); + textSprite->setFont( font ); + textSprite->setCacheMode(QGraphicsItem::DeviceCoordinateCache); + + shield = 0; + shieldOn = FALSE; + refreshRate = REFRESH_DELAY; + + initialized = readSprites(); + + shieldTimer = new QTimer( this ); + connect( shieldTimer, SIGNAL(timeout()), this, SLOT(hideShield()) ); + mTimerId = -1; + + shipPower = MAX_POWER_LEVEL; + vitalsChanged = TRUE; + can_destroy_powerups = FALSE; + + mPaused = TRUE; + + if ( !initialized ) { + textSprite->setHtml( tr("<font color=red>Error: Cannot read sprite images</font>") ); + textSprite->setPos( (field.width()-textSprite->boundingRect().width()) / 2, + (field.height()-textSprite->boundingRect().height()) / 2 ); + } +} + +// - - - + +KAsteroidsView::~KAsteroidsView() +{ +} + +// - - - + +void KAsteroidsView::reset() +{ + if ( !initialized ) + return; + rocks.clear(); + missiles.clear(); + bits.clear(); + powerups.clear(); + exhaust.clear(); + + shotsFired = 0; + shotsHit = 0; + + rockSpeed = 1.0; + powerupSpeed = 1.0; + mFrameNum = 0; + mPaused = FALSE; + + ship->hide(); + shield->hide(); +/* + if ( mTimerId >= 0 ) { + killTimer( mTimerId ); + mTimerId = -1; + } +*/ +} + +// - -- + +void KAsteroidsView::newGame() +{ + if ( !initialized ) + return; + if ( shieldOn ) + { + shield->hide(); + shieldOn = FALSE; + } + reset(); + if ( mTimerId < 0 ) + mTimerId = startTimer( REFRESH_DELAY ); + emit updateVitals(); +} + +// - - - + +void KAsteroidsView::endGame() +{ +} + +void KAsteroidsView::pause( bool p ) +{ + if ( !initialized ) + return; + if ( !mPaused && p ) { + if ( mTimerId >= 0 ) { + killTimer( mTimerId ); + mTimerId = -1; + } + } else if ( mPaused && !p ) + mTimerId = startTimer( REFRESH_DELAY ); + mPaused = p; +} + +// - - - + +void KAsteroidsView::newShip() +{ + if ( !initialized ) + return; + ship->setPos( width()/2, height()/2 ); + ship->setFrame( 0 ); + shield->setPos( width()/2, height()/2 ); + shield->setFrame( 0 ); + ship->setVelocity( 0.0, 0.0 ); + shipDx = 0; + shipDy = 0; + shipAngle = 0; + rotateL = FALSE; + rotateR = FALSE; + thrustShip = FALSE; + shootShip = FALSE; + brakeShip = FALSE; + teleportShip = FALSE; + shieldOn = TRUE; + shootDelay = 0; + shipPower = MAX_POWER_LEVEL; + rotateRate = ROTATE_RATE; + rotateSlow = 0; + + mBrakeCount = 0; + mTeleportCount = 0; + mShootCount = 0; + + ship->show(); + shield->show(); + mShieldCount = 1; // just in case the ship appears on a rock. + shieldTimer->start( 1000, TRUE ); +} + +void KAsteroidsView::setShield( bool s ) +{ + if ( !initialized ) + return; + if ( shieldTimer->isActive() && !s ) { + shieldTimer->stop(); + hideShield(); + } else { + shieldOn = s && mShieldCount; + } +} + +void KAsteroidsView::brake( bool b ) +{ + if ( !initialized ) + return; + if ( mBrakeCount ) + { + if ( brakeShip && !b ) + { + rotateL = FALSE; + rotateR = FALSE; + thrustShip = FALSE; + rotateRate = ROTATE_RATE; + } + + brakeShip = b; + } +} + +// - - - + +bool KAsteroidsView::readSprites() +{ + QString sprites_prefix = ":/trolltech/examples/graphicsview/portedasteroids/sprites/"; + + int i = 0; + while ( kas_animations[i].id ) + { + QList<QPixmap> anim; + QString wildcard = sprites_prefix + kas_animations[i].path; + wildcard.replace("%1", "*"); + QFileInfo fi(wildcard); + foreach (QString entry, QDir(fi.path(), fi.fileName()).entryList()) + anim << QPixmap(fi.path() + "/" + entry); + animation.insert( kas_animations[i].id, anim ); + i++; + } + + ship = new AnimatedPixmapItem( animation[ID_SHIP], &field ); + ship->hide(); + + shield = new KShield( animation[ID_SHIELD], &field ); + shield->hide(); + + return (!ship->image(0).isNull() && !shield->image(0).isNull()); +} + +// - - - + +void KAsteroidsView::addRocks( int num ) +{ + if ( !initialized ) + return; + for ( int i = 0; i < num; i++ ) + { + KRock *rock = new KRock( animation[ID_ROCK_LARGE], &field, + ID_ROCK_LARGE, randInt(2), randInt(2) ? -1 : 1 ); + double dx = (2.0 - randDouble()*4.0) * rockSpeed; + double dy = (2.0 - randDouble()*4.0) * rockSpeed; + rock->setVelocity( dx, dy ); + rock->setFrame( randInt( rock->frameCount() ) ); + if ( dx > 0 ) + { + if ( dy > 0 ) + rock->setPos( 5, 5 ); + else + rock->setPos( 5, field.height() - 25 ); + rock->setFrame( 0 ); + } + else + { + if ( dy > 0 ) + rock->setPos( field.width() - 25, 5 ); + else + rock->setPos( field.width() - 25, field.height() - 25 ); + rock->setFrame( 0 ); + } + rock->show(); + rocks.append( rock ); + } +} + +// - - - + +void KAsteroidsView::showText( const QString &text, const QColor &color, bool scroll ) +{ + if ( !initialized ) + return; + textSprite->setHtml( QString("<font color=#%1%2%3>%4</font>") + .arg(color.red(), 2, 16, QLatin1Char('0')) + .arg(color.green(), 2, 16, QLatin1Char('0')) + .arg(color.blue(), 2, 16, QLatin1Char('0')) + .arg(text) ); + Q_UNUSED(color); + // ### Porting: no such thing textSprite->setColor( color ); + + if ( scroll ) { + textSprite->setPos( (field.width()-textSprite->boundingRect().width()) / 2, + -textSprite->boundingRect().height() ); + textDy = TEXT_SPEED; + } else { + textSprite->setPos( (field.width()-textSprite->boundingRect().width()) / 2, + (field.height()-textSprite->boundingRect().height()) / 2 ); + textDy = 0; + } + textSprite->show(); +} + +// - - - + +void KAsteroidsView::hideText() +{ + textDy = -TEXT_SPEED; +} + +// - - - + +void KAsteroidsView::resizeEvent(QResizeEvent* event) +{ + QWidget::resizeEvent(event); + field.setSceneRect(0, 0, width()-4, height()-4); + view.resize(width(),height()); +} + +// - - - + +void KAsteroidsView::timerEvent( QTimerEvent * ) +{ + field.advance(); + + AnimatedPixmapItem *rock; + + // move rocks forward + for ( rock = rocks.first(); rock; rock = rocks.next() ) { + ((KRock *)rock)->nextFrame(); + wrapSprite( rock ); + } + + wrapSprite( ship ); + + // check for missile collision with rocks. + processMissiles(); + + // these are generated when a ship explodes + for ( KBit *bit = bits.first(); bit; bit = bits.next() ) + { + if ( bit->expired() ) + { + bits.removeRef( bit ); + } + else + { + bit->growOlder(); + bit->setFrame( ( bit->frame()+1 ) % bit->frameCount() ); + } + } + + for ( KExhaust *e = exhaust.first(); e; e = exhaust.next() ) + exhaust.removeRef( e ); + + // move / rotate ship. + // check for collision with a rock. + processShip(); + + // move powerups and check for collision with player and missiles + processPowerups(); + + if ( textSprite->isVisible() ) + { + if ( textDy < 0 && + textSprite->boundingRect().y() <= -textSprite->boundingRect().height() ) { + textSprite->hide(); + } else { + textSprite->moveBy( 0, textDy ); + } + + if ( textSprite->sceneBoundingRect().y() > (field.height()-textSprite->boundingRect().height())/2 ) + textDy = 0; + } + + if ( vitalsChanged && !(mFrameNum % 10) ) { + emit updateVitals(); + vitalsChanged = FALSE; + } + + mFrameNum++; +} + +void KAsteroidsView::wrapSprite( QGraphicsItem *s ) +{ + int x = int(s->x() + s->boundingRect().width() / 2); + int y = int(s->y() + s->boundingRect().height() / 2); + + if ( x > field.width() ) + s->setPos( s->x() - field.width(), s->y() ); + else if ( x < 0 ) + s->setPos( field.width() + s->x(), s->y() ); + + if ( y > field.height() ) + s->setPos( s->x(), s->y() - field.height() ); + else if ( y < 0 ) + s->setPos( s->x(), field.height() + s->y() ); +} + +// - - - + +void KAsteroidsView::rockHit( AnimatedPixmapItem *hit ) +{ + KPowerup *nPup = 0; + int rnd = int(randDouble()*30.0) % 30; + switch( rnd ) + { + case 4: + case 5: + nPup = new KPowerup( animation[ID_ENERGY_POWERUP], &field, + ID_ENERGY_POWERUP ); + break; + case 10: +// nPup = new KPowerup( animation[ID_TELEPORT_POWERUP], &field, +// ID_TELEPORT_POWERUP ); + break; + case 15: + nPup = new KPowerup( animation[ID_BRAKE_POWERUP], &field, + ID_BRAKE_POWERUP ); + break; + case 20: + nPup = new KPowerup( animation[ID_SHIELD_POWERUP], &field, + ID_SHIELD_POWERUP ); + break; + case 24: + case 25: + nPup = new KPowerup( animation[ID_SHOOT_POWERUP], &field, + ID_SHOOT_POWERUP ); + break; + } + if ( nPup ) + { + double r = 0.5 - randDouble(); + nPup->setPos( hit->x(), hit->y() ); + nPup->setFrame( 0 ); + nPup->setVelocity( hit->xVelocity() + r, hit->yVelocity() + r ); + powerups.append( nPup ); + } + + if ( hit->type() == ID_ROCK_LARGE || hit->type() == ID_ROCK_MEDIUM ) + { + // break into smaller rocks + double addx[4] = { 1.0, 1.0, -1.0, -1.0 }; + double addy[4] = { -1.0, 1.0, -1.0, 1.0 }; + + double dx = hit->xVelocity(); + double dy = hit->yVelocity(); + + double maxRockSpeed = MAX_ROCK_SPEED * rockSpeed; + if ( dx > maxRockSpeed ) + dx = maxRockSpeed; + else if ( dx < -maxRockSpeed ) + dx = -maxRockSpeed; + if ( dy > maxRockSpeed ) + dy = maxRockSpeed; + else if ( dy < -maxRockSpeed ) + dy = -maxRockSpeed; + + AnimatedPixmapItem *nrock; + + for ( int i = 0; i < 4; i++ ) + { + double r = rockSpeed/2 - randDouble()*rockSpeed; + if ( hit->type() == ID_ROCK_LARGE ) + { + nrock = new KRock( animation[ID_ROCK_MEDIUM], &field, + ID_ROCK_MEDIUM, randInt(2), randInt(2) ? -1 : 1 ); + emit rockHit( 0 ); + } + else + { + nrock = new KRock( animation[ID_ROCK_SMALL], &field, + ID_ROCK_SMALL, randInt(2), randInt(2) ? -1 : 1 ); + emit rockHit( 1 ); + } + + nrock->setPos( hit->x(), hit->y() ); + nrock->setFrame( 0 ); + nrock->setVelocity( dx+addx[i]*rockSpeed+r, dy+addy[i]*rockSpeed+r ); + nrock->setFrame( randInt( nrock->frameCount() ) ); + rocks.append( nrock ); + } + } + else if ( hit->type() == ID_ROCK_SMALL ) + emit rockHit( 2 ); + rocks.removeRef( hit ); + if ( rocks.count() == 0 ) + emit rocksRemoved(); +} + +void KAsteroidsView::reducePower( int val ) +{ + shipPower -= val; + if ( shipPower <= 0 ) + { + shipPower = 0; + thrustShip = FALSE; + if ( shieldOn ) + { + shieldOn = FALSE; + shield->hide(); + } + } + vitalsChanged = TRUE; +} + +void KAsteroidsView::addExhaust( double x, double y, double dx, + double dy, int count ) +{ + for ( int i = 0; i < count; i++ ) + { + KExhaust *e = new KExhaust( animation[ID_EXHAUST], &field ); + e->setPos( x + 2 - randDouble()*4, y + 2 - randDouble()*4 ); + e->setVelocity( dx, dy ); + exhaust.append( e ); + } +} + +void KAsteroidsView::processMissiles() +{ + KMissile *missile; + + // if a missile has hit a rock, remove missile and break rock into smaller + // rocks or remove completely. + Q3PtrListIterator<KMissile> it(missiles); + + for ( ; it.current(); ++it ) + { + missile = it.current(); + missile->growOlder(); + + if ( missile->expired() ) + { + missiles.removeRef( missile ); + continue; + } + + wrapSprite( missile ); + + QList<QGraphicsItem *> hits = missile->collidingItems(Qt::IntersectsItemBoundingRect); + QList<QGraphicsItem *>::Iterator hit; + for ( hit = hits.begin(); hit != hits.end(); ++hit ) + { + if ( (*hit)->type() >= ID_ROCK_LARGE && + (*hit)->type() <= ID_ROCK_SMALL && (*hit)->collidesWithItem(missile) ) + { + shotsHit++; + rockHit( static_cast<AnimatedPixmapItem *>(*hit) ); + missiles.removeRef( missile ); + break; + } + } + } +} + +// - - - + +void KAsteroidsView::processShip() +{ + if ( ship->isVisible() ) + { + if ( shieldOn ) + { + shield->show(); + reducePower( SHIELD_ON_COST ); + static int sf = 0; + sf++; + + if ( sf % 2 ) + shield->setFrame( (shield->frame()+1) % shield->frameCount() ); + shield->setPos( ship->x() - 9, ship->y() - 9 ); + + QList<QGraphicsItem *> hits = shield->collidingItems(Qt::IntersectsItemBoundingRect); + QList<QGraphicsItem *>::Iterator it; + for ( it = hits.begin(); it != hits.end(); ++it ) + { + if ( (*it)->type() >= ID_ROCK_LARGE && + (*it)->type() <= ID_ROCK_SMALL && (*it)->collidesWithItem(shield) ) + { + int factor; + switch ( (*it)->type() ) + { + case ID_ROCK_LARGE: + factor = 3; + break; + + case ID_ROCK_MEDIUM: + factor = 2; + break; + + default: + factor = 1; + } + + if ( factor > mShieldCount ) + { + // shield not strong enough + shieldOn = FALSE; + break; + } + rockHit( static_cast<AnimatedPixmapItem *>(*it) ); + // the more shields we have the less costly + reducePower( factor * (SHIELD_HIT_COST - mShieldCount*2) ); + } + } + } + + if ( !shieldOn ) + { + shield->hide(); + QList<QGraphicsItem *> hits = ship->collidingItems(Qt::IntersectsItemBoundingRect); + QList<QGraphicsItem *>::Iterator it; + for ( it = hits.begin(); it != hits.end(); ++it ) + { + if ( (*it)->type() >= ID_ROCK_LARGE && + (*it)->type() <= ID_ROCK_SMALL && (*it)->collidesWithItem(ship)) + { + KBit *bit; + for ( int i = 0; i < 12; i++ ) + { + bit = new KBit( animation[ID_BIT], &field ); + bit->setPos( ship->x() + 5 - randDouble() * 10, + ship->y() + 5 - randDouble() * 10 ); + bit->setFrame( randInt(bit->frameCount()) ); + bit->setVelocity( 1-randDouble()*2, + 1-randDouble()*2 ); + bit->setDeath( 60 + randInt(60) ); + bits.append( bit ); + } + ship->hide(); + shield->hide(); + emit shipKilled(); + break; + } + } + } + + + if ( rotateSlow ) + rotateSlow--; + + if ( rotateL ) + { + shipAngle -= rotateSlow ? 1 : rotateRate; + if ( shipAngle < 0 ) + shipAngle += SHIP_STEPS; + } + + if ( rotateR ) + { + shipAngle += rotateSlow ? 1 : rotateRate; + if ( shipAngle >= SHIP_STEPS ) + shipAngle -= SHIP_STEPS; + } + + double angle = shipAngle * PI_X_2 / SHIP_STEPS; + double cosangle = cos( angle ); + double sinangle = sin( angle ); + + if ( brakeShip ) + { + thrustShip = FALSE; + rotateL = FALSE; + rotateR = FALSE; + rotateRate = ROTATE_RATE; + if ( fabs(shipDx) < 2.5 && fabs(shipDy) < 2.5 ) + { + shipDx = 0.0; + shipDy = 0.0; + ship->setVelocity( shipDx, shipDy ); + brakeShip = FALSE; + } + else + { + double motionAngle = atan2( -shipDy, -shipDx ); + if ( angle > M_PI ) + angle -= PI_X_2; + double angleDiff = angle - motionAngle; + if ( angleDiff > M_PI ) + angleDiff = PI_X_2 - angleDiff; + else if ( angleDiff < -M_PI ) + angleDiff = PI_X_2 + angleDiff; + double fdiff = fabs( angleDiff ); + if ( fdiff > 0.08 ) + { + if ( angleDiff > 0 ) + rotateL = TRUE; + else if ( angleDiff < 0 ) + rotateR = TRUE; + if ( fdiff > 0.6 ) + rotateRate = mBrakeCount + 1; + else if ( fdiff > 0.4 ) + rotateRate = 2; + else + rotateRate = 1; + + if ( rotateRate > 5 ) + rotateRate = 5; + } + else if ( fabs(shipDx) > 1 || fabs(shipDy) > 1 ) + { + thrustShip = TRUE; + // we'll make braking a bit faster + shipDx += cosangle/6 * (mBrakeCount - 1); + shipDy += sinangle/6 * (mBrakeCount - 1); + reducePower( BRAKE_ON_COST ); + addExhaust( ship->x() + 20 - cosangle*22, + ship->y() + 20 - sinangle*22, + shipDx-cosangle, shipDy-sinangle, + mBrakeCount+1 ); + } + } + } + + if ( thrustShip ) + { + // The ship has a terminal velocity, but trying to go faster + // still uses fuel (can go faster diagonally - don't care). + double thrustx = cosangle/4; + double thrusty = sinangle/4; + if ( fabs(shipDx + thrustx) < MAX_SHIP_SPEED ) + shipDx += thrustx; + if ( fabs(shipDy + thrusty) < MAX_SHIP_SPEED ) + shipDy += thrusty; + ship->setVelocity( shipDx, shipDy ); + reducePower( 1 ); + addExhaust( ship->x() + 20 - cosangle*20, + ship->y() + 20 - sinangle*20, + shipDx-cosangle, shipDy-sinangle, 3 ); + } + + ship->setFrame( shipAngle >> 1 ); + + if ( shootShip ) + { + if ( !shootDelay && (int)missiles.count() < mShootCount + 2 ) + { + KMissile *missile = new KMissile( animation[ID_MISSILE], &field ); + missile->setPos( 21+ship->x()+cosangle*21, + 21+ship->y()+sinangle*21 ); + missile->setFrame( 0 ); + missile->setVelocity( shipDx + cosangle*MISSILE_SPEED, + shipDy + sinangle*MISSILE_SPEED ); + missiles.append( missile ); + shotsFired++; + reducePower( 1 ); + + shootDelay = 5; + } + + if ( shootDelay ) + shootDelay--; + } + + if ( teleportShip ) + { + int ra = qrand() % 10; + if( ra == 0 ) + ra += qrand() % 20; + int xra = ra * 60 + ( (qrand() % 20) * (qrand() % 20) ); + int yra = ra * 50 - ( (qrand() % 20) * (qrand() % 20) ); + ship->setPos( xra, yra ); + } + + vitalsChanged = TRUE; + } +} + +// - - - + +void KAsteroidsView::processPowerups() +{ + if ( !powerups.isEmpty() ) + { + // if player gets the powerup remove it from the screen, if option + // "Can destroy powerups" is enabled and a missile hits the powerup + // destroy it + + KPowerup *pup; + Q3PtrListIterator<KPowerup> it( powerups ); + + for( ; it.current(); ++it ) + { + pup = it.current(); + pup->growOlder(); + + if( pup->expired() ) + { + powerups.removeRef( pup ); + continue; + } + + wrapSprite( pup ); + + QList<QGraphicsItem *> hits = pup->collidingItems(); + QList<QGraphicsItem *>::Iterator it; + for ( it = hits.begin(); it != hits.end(); ++it ) + { + if ( (*it) == ship ) + { + switch( pup->type() ) + { + case ID_ENERGY_POWERUP: + shipPower += 150; + if ( shipPower > MAX_POWER_LEVEL ) + shipPower = MAX_POWER_LEVEL; + break; + case ID_TELEPORT_POWERUP: + mTeleportCount++; + break; + case ID_BRAKE_POWERUP: + if ( mBrakeCount < MAX_BRAKES ) + mBrakeCount++; + break; + case ID_SHIELD_POWERUP: + if ( mShieldCount < MAX_SHIELDS ) + mShieldCount++; + break; + case ID_SHOOT_POWERUP: + if ( mShootCount < MAX_FIREPOWER ) + mShootCount++; + break; + } + + powerups.removeRef( pup ); + vitalsChanged = TRUE; + } + else if ( (*it) == shield ) + { + powerups.removeRef( pup ); + } + else if ( (*it)->type() == ID_MISSILE ) + { + if ( can_destroy_powerups ) + { + powerups.removeRef( pup ); + } + } + } + } + } // -- if( powerups.isEmpty() ) +} + +// - - - + +void KAsteroidsView::hideShield() +{ + shield->hide(); + mShieldCount = 0; + shieldOn = FALSE; +} + +double KAsteroidsView::randDouble() +{ + int v = qrand(); + return (double)v / (double)RAND_MAX; +} + +int KAsteroidsView::randInt( int range ) +{ + return qrand() % range; +} + +void KAsteroidsView::showEvent( QShowEvent *e ) +{ +#if defined( QT_LICENSE_PROFESSIONAL ) + static bool wasThere = FALSE; + + if ( !wasThere ) { + wasThere = TRUE; + QMessageBox::information( this, tr("QGraphicsView demo"), + tr("This game has been implemented using the QGraphicsView class.\n" + "The QGraphicsView class is not part of the Light Platform Edition. Please \n" + "contact Qt Software if you want to upgrade to the Full Platform Edition.") ); + } +#endif + + QWidget::showEvent( e ); +} diff --git a/examples/graphicsview/portedasteroids/view.h b/examples/graphicsview/portedasteroids/view.h new file mode 100644 index 0000000..d055f29 --- /dev/null +++ b/examples/graphicsview/portedasteroids/view.h @@ -0,0 +1,184 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +/* + * KAsteroids - Copyright (c) Martin R. Jones 1997 + * + * Part of the KDE project + */ + +#ifndef __AST_VIEW_H__ +#define __AST_VIEW_H__ + +#include <qwidget.h> +#include <q3ptrlist.h> +#include <q3intdict.h> +#include <qtimer.h> +#include <QGraphicsScene> +#include <QGraphicsView> +//Added by qt3to4: +#include <QTimerEvent> +#include <QShowEvent> +#include <QResizeEvent> +#include "sprites.h" + +#define MAX_POWER_LEVEL 1000 + +class KAsteroidsView : public QWidget +{ + Q_OBJECT +public: + KAsteroidsView( QWidget *parent = 0, const char *name = 0 ); + virtual ~KAsteroidsView(); + + int refreshRate; + + void reset(); + void setRockSpeed( double rs ) { rockSpeed = rs; } + void addRocks( int num ); + void newGame(); + void endGame(); + void newShip(); + + void rotateLeft( bool r ) { rotateL = r; rotateSlow = 5; } + void rotateRight( bool r ) { rotateR = r; rotateSlow = 5; } + void thrust( bool t ) { thrustShip = t && shipPower > 0; } + void shoot( bool s ) { shootShip = s; shootDelay = 0; } + void setShield( bool s ); + void teleport( bool te) { teleportShip = te && mTeleportCount; } + void brake( bool b ); + void pause( bool p); + + void showText( const QString &text, const QColor &color, bool scroll=TRUE ); + void hideText(); + + int shots() const { return shotsFired; } + int hits() const { return shotsHit; } + int power() const { return shipPower; } + + int teleportCount() const { return mTeleportCount; } + int brakeCount() const { return mBrakeCount; } + int shieldCount() const { return mShieldCount; } + int shootCount() const { return mShootCount; } + +signals: + void shipKilled(); + void rockHit( int size ); + void rocksRemoved(); + void updateVitals(); + +private slots: + void hideShield(); + +protected: + bool readSprites(); + void wrapSprite( QGraphicsItem * ); + void rockHit( AnimatedPixmapItem * ); + void reducePower( int val ); + void addExhaust( double x, double y, double dx, double dy, int count ); + void processMissiles(); + void processShip(); + void processPowerups(); + void processShield(); + double randDouble(); + int randInt( int range ); + + virtual void resizeEvent( QResizeEvent *event ); + virtual void timerEvent( QTimerEvent * ); + + void showEvent( QShowEvent * ); + +private: + QGraphicsScene field; + QGraphicsView view; + QMap<int, QList<QPixmap> > animation; + Q3PtrList<AnimatedPixmapItem> rocks; + Q3PtrList<KMissile> missiles; + Q3PtrList<KBit> bits; + Q3PtrList<KExhaust> exhaust; + Q3PtrList<KPowerup> powerups; + KShield *shield; + AnimatedPixmapItem *ship; + QGraphicsTextItem *textSprite; + + bool rotateL; + bool rotateR; + bool thrustShip; + bool shootShip; + bool teleportShip; + bool brakeShip; + bool pauseShip; + bool shieldOn; + + bool vitalsChanged; + + int shipAngle; + int rotateSlow; + int rotateRate; + int shipPower; + + int shotsFired; + int shotsHit; + int shootDelay; + + int mBrakeCount; + int mShieldCount; + int mTeleportCount; + int mShootCount; + + double shipDx; + double shipDy; + + int textDy; + int mFrameNum; + bool mPaused; + int mTimerId; + + double rockSpeed; + double powerupSpeed; + + bool can_destroy_powerups; + + QTimer *shieldTimer; + bool initialized; +}; + +#endif |