source: trunk/examples/graphicsview/portedasteroids/sprites.h@ 846

Last change on this file since 846 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 4.8 KB
RevLine 
[2]1/****************************************************************************
2**
[846]3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
[561]4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
[2]6**
7** This file is part of the examples of the Qt Toolkit.
8**
[846]9** $QT_BEGIN_LICENSE:BSD$
10** You may use this file under the terms of the BSD license as follows:
[2]11**
[846]12** "Redistribution and use in source and binary forms, with or without
13** modification, are permitted provided that the following conditions are
14** met:
15** * Redistributions of source code must retain the above copyright
16** notice, this list of conditions and the following disclaimer.
17** * Redistributions in binary form must reproduce the above copyright
18** notice, this list of conditions and the following disclaimer in
19** the documentation and/or other materials provided with the
20** distribution.
21** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
22** the names of its contributors may be used to endorse or promote
23** products derived from this software without specific prior written
24** permission.
[2]25**
[846]26** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
[2]37** $QT_END_LICENSE$
38**
39****************************************************************************/
40
41/*
42 * KAsteroids - Copyright (c) Martin R. Jones 1997
43 *
44 * Part of the KDE project
45 */
46
47#ifndef __SPRITES_H__
48#define __SPRITES_H__
49
50#include "animateditem.h"
51
52#define ID_ROCK_LARGE 1024
53#define ID_ROCK_MEDIUM 1025
54#define ID_ROCK_SMALL 1026
55
56#define ID_MISSILE 1030
57
58#define ID_BIT 1040
59#define ID_EXHAUST 1041
60
61#define ID_ENERGY_POWERUP 1310
62#define ID_TELEPORT_POWERUP 1311
63#define ID_BRAKE_POWERUP 1312
64#define ID_SHIELD_POWERUP 1313
65#define ID_SHOOT_POWERUP 1314
66
67#define ID_SHIP 1350
68#define ID_SHIELD 1351
69
70#define MAX_SHIELD_AGE 350
71#define MAX_POWERUP_AGE 500
72#define MAX_MISSILE_AGE 40
73
74class KMissile : public AnimatedPixmapItem
75{
76public:
77 KMissile( const QList<QPixmap> &s, QGraphicsScene *c ) : AnimatedPixmapItem( s, c )
78 { myAge = 0; }
79
80 virtual int type() const { return ID_MISSILE; }
81
82 void growOlder() { myAge++; }
83 bool expired() { return myAge > MAX_MISSILE_AGE; }
84
85private:
86 int myAge;
87};
88
89class KBit : public AnimatedPixmapItem
90{
91public:
92 KBit( const QList<QPixmap> &s, QGraphicsScene *c ) : AnimatedPixmapItem( s, c )
93 { death = 7; }
94
95 virtual int type() const { return ID_BIT; }
96
97 void setDeath( int d ) { death = d; }
98 void growOlder() { death--; }
99 bool expired() { return death <= 0; }
100
101private:
102 int death;
103};
104
105class KExhaust : public AnimatedPixmapItem
106{
107public:
108 KExhaust( const QList<QPixmap> &s, QGraphicsScene *c ) : AnimatedPixmapItem( s, c )
109 { death = 1; }
110
111 virtual int type() const { return ID_EXHAUST; }
112
113 void setDeath( int d ) { death = d; }
114 void growOlder() { death--; }
115 bool expired() { return death <= 0; }
116
117private:
118 int death;
119};
120
121class KPowerup : public AnimatedPixmapItem
122{
123public:
124 KPowerup( const QList<QPixmap> &s, QGraphicsScene *c, int t ) : AnimatedPixmapItem( s, c ),
125 myAge( 0 ), _type(t) { }
126
127 virtual int type() const { return _type; }
128
129 void growOlder() { myAge++; }
130 bool expired() const { return myAge > MAX_POWERUP_AGE; }
131
132protected:
133 int myAge;
134 int _type;
135};
136
137class KRock : public AnimatedPixmapItem
138{
139public:
140 KRock (const QList<QPixmap> &s, QGraphicsScene *c, int t, int sk, int st) : AnimatedPixmapItem( s, c )
141 { _type = t; skip = cskip = sk; step = st; }
142
143 void nextFrame()
144 {
145 if (cskip-- <= 0) {
146 setFrame( (frame()+step+frameCount())%frameCount() );
147 cskip = QABS(skip);
148 }
149 }
150
151 virtual int type() const { return _type; }
152
153private:
154 int _type;
155 int skip;
156 int cskip;
157 int step;
158};
159
160class KShield : public AnimatedPixmapItem
161{
162public:
163 KShield( QList<QPixmap> &s, QGraphicsScene *c )
164 : AnimatedPixmapItem( s, c ) {}
165
166 virtual int type() const { return ID_SHIELD; }
167};
168
169#endif
Note: See TracBrowser for help on using the repository browser.