Debian Codegraph @

src/jj2/level/event/jj2event.cpp

raw symbols SCIP
1
2 /**
3 *
4 * @file jj2event.cpp
5 *
6 * Part of the OpenJazz project
7 *
8 * @par History:
9 * - 23rd August 2005: Created level.c
10 * - 22nd July 2008: Created levelload.c from parts of level.c
11 * - 3rd February 2009: Renamed level.c to level.cpp
12 * - 19th July 2009: Added parts of levelload.cpp to level.cpp
13 * - 29th June 2010: Created jj2level.cpp from parts of level.cpp
14 * - 2nd July 2010: Created jj2event.cpp from parts of jj2level.cpp
15 *
16 * @par Licence:
17 * Copyright (c) 2005-2012 AJ Thomson
18 *
19 * OpenJazz is distributed under the terms of
20 * the GNU General Public License, version 2.0
21 *
22 * @par Description:
23 * Deals with the creating and freeing of JJ2 events.
24 *
25 */
26
27
28 #include "jj2event.h"
29
30 #include "level/level.h"
31
32
33 /**
34 * Create event
35 *
36 * @param newNext Next event
37 * @param gridX X-coordinate
38 * @param gridY Y-coordinate
39 * @param newType Event type
40 * @param newProperties Event properties
41 */
42 JJ2Event::JJ2Event (JJ2Event* newNext, int gridX, int gridY, unsigned char newType, int newProperties) {
43
44 x = TTOF(gridX);
45 y = TTOF(gridY);
46 dx = 0;
47 dy = 0;
48
49 next = newNext;
50
51 type = newType;
52 properties = newProperties;
53
54 endTime = 0;
55
56 flipped = false;
57
58 }
59
60
61 /**
62 * Delete all events
63 */
64 JJ2Event::~JJ2Event () {
65
66 if (next) delete next;
67
68 }
69
70
71 /**
72 * Create pickup event
73 *
74 * @param newNext Next event
75 * @param gridX X-coordinate
76 * @param gridY Y-coordinate
77 * @param newType Event type
78 * @param TSF Whether or not the level uses TSF animations
79 * @param newProperties Event properties
80 */
81 PickupJJ2Event::PickupJJ2Event (JJ2Event* newNext, int gridX, int gridY, unsigned char newType, bool TSF, int newProperties) : JJ2Event(newNext, gridX, gridY, newType, newProperties) {
82
83 floating = true;
84 animSet = TSF? 71: 67;
85
86 }
87
88
89 /**
90 * Delete pickup event
91 */
92 PickupJJ2Event::~PickupJJ2Event () {
93
94 }
95
96
97 /**
98 * Create ammo pickup event
99 *
100 * @param newNext Next event
101 * @param gridX X-coordinate
102 * @param gridY Y-coordinate
103 * @param newType Event type
104 * @param TSF Whether or not the level uses TSF animations
105 */
106 AmmoJJ2Event::AmmoJJ2Event (JJ2Event* newNext, int gridX, int gridY, unsigned char newType, bool TSF) : PickupJJ2Event(newNext, gridX, gridY, newType, TSF, 0) {
107
108 }
109
110
111 /**
112 * Delete ammo pickup event
113 */
114 AmmoJJ2Event::~AmmoJJ2Event () {
115
116 }
117
118
119 /**
120 * Create coin/gem pickup event
121 *
122 * @param newNext Next event
123 * @param gridX X-coordinate
124 * @param gridY Y-coordinate
125 * @param newType Event type
126 * @param TSF Whether or not the level uses TSF animations
127 */
128 CoinGemJJ2Event::CoinGemJJ2Event (JJ2Event* newNext, int gridX, int gridY, unsigned char newType, bool TSF) : PickupJJ2Event(newNext, gridX, gridY, newType, TSF, 0) {
129
130 }
131
132
133 /**
134 * Delete coin/gem pickup event
135 */
136 CoinGemJJ2Event::~CoinGemJJ2Event () {
137
138 }
139
140
141 /**
142 * Create food pickup event
143 *
144 * @param newNext Next event
145 * @param gridX X-coordinate
146 * @param gridY Y-coordinate
147 * @param newType Event type
148 * @param TSF Whether or not the level uses TSF animations
149 */
150 FoodJJ2Event::FoodJJ2Event (JJ2Event* newNext, int gridX, int gridY, unsigned char newType, bool TSF) : PickupJJ2Event(newNext, gridX, gridY, newType, TSF, 0) {
151
152 }
153
154
155 /**
156 * Delete food pickup event
157 */
158 FoodJJ2Event::~FoodJJ2Event () {
159
160 }
161
162
163 /**
164 * Create spring event
165 *
166 * @param newNext Next event
167 * @param gridX X-coordinate
168 * @param gridY Y-coordinate
169 * @param newType Event type
170 * @param TSF Whether or not the level uses TSF animations
171 * @param newProperties Event properties
172 */
173 SpringJJ2Event::SpringJJ2Event (JJ2Event* newNext, int gridX, int gridY, unsigned char newType, bool TSF, int newProperties) : JJ2Event(newNext, gridX, gridY, newType, newProperties) {
174
175 animSet = TSF? 96: 92;
176
177 }
178
179
180 /**
181 * Delete spring event
182 */
183 SpringJJ2Event::~SpringJJ2Event () {
184
185 }
186
187
188 /**
189 * Create placeholder event
190 *
191 * @param newNext Next event
192 * @param gridX X-coordinate
193 * @param gridY Y-coordinate
194 * @param newType Event type
195 * @param TSF Whether or not the level uses TSF animations
196 * @param newProperties Event properties
197 */
198 OtherJJ2Event::OtherJJ2Event (JJ2Event* newNext, int gridX, int gridY, unsigned char newType, bool TSF, int newProperties) : JJ2Event(newNext, gridX, gridY, newType, newProperties) {
199
200 animSet = TSF? 71: 67;
201
202 }
203
204
205 /**
206 * Delete placeholder event
207 */
208 OtherJJ2Event::~OtherJJ2Event () {
209
210 }
211
212
213 /**
214 * Initiate the destruction of the event
215 *
216 * @param ticks Time
217 */
218 void JJ2Event::destroy (unsigned int ticks) {
219
220 endTime = ticks + 500;
221
222 }
223
224
225 /**
226 * Get the event's type
227 *
228 * @return Event type
229 */
230 unsigned char JJ2Event::getType () {
231
232 return type;
233
234 }
235
236
237 /**
238 * Delete this event
239 *
240 * @return The next event
241 */
242 JJ2Event* JJ2Event::remove () {
243
244 JJ2Event *oldNext;
245
246 oldNext = next;
247 next = NULL;
248 delete this;
249
250 return oldNext;
251
252 }