source: branches/4.5.1/examples/graphicsview/portedasteroids/sprites.h

Last change on this file was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 4.7 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information (qt-info@nokia.com)
5**
6** This file is part of the examples of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you are unsure which license is appropriate for your use, please
37** contact the sales department at qt-sales@nokia.com.
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42/*
43 * KAsteroids - Copyright (c) Martin R. Jones 1997
44 *
45 * Part of the KDE project
46 */
47
48#ifndef __SPRITES_H__
49#define __SPRITES_H__
50
51#include "animateditem.h"
52
53#define ID_ROCK_LARGE 1024
54#define ID_ROCK_MEDIUM 1025
55#define ID_ROCK_SMALL 1026
56
57#define ID_MISSILE 1030
58
59#define ID_BIT 1040
60#define ID_EXHAUST 1041
61
62#define ID_ENERGY_POWERUP 1310
63#define ID_TELEPORT_POWERUP 1311
64#define ID_BRAKE_POWERUP 1312
65#define ID_SHIELD_POWERUP 1313
66#define ID_SHOOT_POWERUP 1314
67
68#define ID_SHIP 1350
69#define ID_SHIELD 1351
70
71#define MAX_SHIELD_AGE 350
72#define MAX_POWERUP_AGE 500
73#define MAX_MISSILE_AGE 40
74
75class KMissile : public AnimatedPixmapItem
76{
77public:
78 KMissile( const QList<QPixmap> &s, QGraphicsScene *c ) : AnimatedPixmapItem( s, c )
79 { myAge = 0; }
80
81 virtual int type() const { return ID_MISSILE; }
82
83 void growOlder() { myAge++; }
84 bool expired() { return myAge > MAX_MISSILE_AGE; }
85
86private:
87 int myAge;
88};
89
90class KBit : public AnimatedPixmapItem
91{
92public:
93 KBit( const QList<QPixmap> &s, QGraphicsScene *c ) : AnimatedPixmapItem( s, c )
94 { death = 7; }
95
96 virtual int type() const { return ID_BIT; }
97
98 void setDeath( int d ) { death = d; }
99 void growOlder() { death--; }
100 bool expired() { return death <= 0; }
101
102private:
103 int death;
104};
105
106class KExhaust : public AnimatedPixmapItem
107{
108public:
109 KExhaust( const QList<QPixmap> &s, QGraphicsScene *c ) : AnimatedPixmapItem( s, c )
110 { death = 1; }
111
112 virtual int type() const { return ID_EXHAUST; }
113
114 void setDeath( int d ) { death = d; }
115 void growOlder() { death--; }
116 bool expired() { return death <= 0; }
117
118private:
119 int death;
120};
121
122class KPowerup : public AnimatedPixmapItem
123{
124public:
125 KPowerup( const QList<QPixmap> &s, QGraphicsScene *c, int t ) : AnimatedPixmapItem( s, c ),
126 myAge( 0 ), _type(t) { }
127
128 virtual int type() const { return _type; }
129
130 void growOlder() { myAge++; }
131 bool expired() const { return myAge > MAX_POWERUP_AGE; }
132
133protected:
134 int myAge;
135 int _type;
136};
137
138class KRock : public AnimatedPixmapItem
139{
140public:
141 KRock (const QList<QPixmap> &s, QGraphicsScene *c, int t, int sk, int st) : AnimatedPixmapItem( s, c )
142 { _type = t; skip = cskip = sk; step = st; }
143
144 void nextFrame()
145 {
146 if (cskip-- <= 0) {
147 setFrame( (frame()+step+frameCount())%frameCount() );
148 cskip = QABS(skip);
149 }
150 }
151
152 virtual int type() const { return _type; }
153
154private:
155 int _type;
156 int skip;
157 int cskip;
158 int step;
159};
160
161class KShield : public AnimatedPixmapItem
162{
163public:
164 KShield( QList<QPixmap> &s, QGraphicsScene *c )
165 : AnimatedPixmapItem( s, c ) {}
166
167 virtual int type() const { return ID_SHIELD; }
168};
169
170#endif
Note: See TracBrowser for help on using the repository browser.