|
@@ -48,13 +48,11 @@
|
48
|
48
|
*/
|
49
|
49
|
#define MAX_DARK 2
|
50
|
50
|
#define MAX_LIGHT 2
|
51
|
|
-#define MAX_SHOT 5
|
|
51
|
+#define MAX_SHOT 2 //5 /* TODO !! */
|
52
|
52
|
#define MAX_SHOT_DARK 2
|
53
|
53
|
#define MAX_SHOT_LIGHT 2
|
54
|
54
|
#define MAX_OBJ ((4 * MAX_DARK) + (4 * MAX_LIGHT) + MAX_SHOT + MAX_SHOT_DARK + MAX_SHOT_LIGHT)
|
55
|
55
|
|
56
|
|
-#define MAX_TRAVEL 128
|
57
|
|
-
|
58
|
56
|
#define POS_SCALE_OBJS 5
|
59
|
57
|
#define POS_OBJS_MAX (INT16_MAX >> (8 - POS_SCALE_OBJS))
|
60
|
58
|
#define POS_OBJS_MIN (-(INT16_MAX >> (8 - POS_SCALE_OBJS)) - 1)
|
|
@@ -80,6 +78,8 @@
|
80
|
78
|
#define RESPAWN_DISTANCE 100 // from center
|
81
|
79
|
#define PLACEMENT_DISTANCE 42 // relative to each other
|
82
|
80
|
|
|
81
|
+#define CHECK_COL_AT_SHOTS
|
|
82
|
+
|
83
|
83
|
struct obj {
|
84
|
84
|
uint8_t active;
|
85
|
85
|
enum SPRITES sprite;
|
|
@@ -151,17 +151,20 @@ static void generate_coords(int8_t *x_c, int8_t *y_c, int8_t center_dist) {
|
151
|
151
|
*y_c = y;
|
152
|
152
|
}
|
153
|
153
|
|
|
154
|
+static void obj_respawn_type(enum SPRITES spr, int8_t center_dist) {
|
|
155
|
+ while (obj_cnt[spr] < obj_max[spr]) {
|
|
156
|
+ int8_t x, y;
|
|
157
|
+ generate_coords(&x, &y, center_dist);
|
|
158
|
+ obj_add(spr, x, y, 0, 0);
|
|
159
|
+ }
|
|
160
|
+}
|
|
161
|
+
|
154
|
162
|
static void obj_respawn(int8_t center_dist) {
|
155
|
163
|
for (uint8_t spr = SPR_LIGHT; spr <= SPR_SHOT_DARK; spr++) {
|
156
|
164
|
if (spr == SPR_SHOT) {
|
157
|
165
|
continue;
|
158
|
166
|
}
|
159
|
|
-
|
160
|
|
- while (obj_cnt[spr] < obj_max[spr]) {
|
161
|
|
- int8_t x, y;
|
162
|
|
- generate_coords(&x, &y, center_dist);
|
163
|
|
- obj_add(spr, x, y, 0, 0);
|
164
|
|
- }
|
|
167
|
+ obj_respawn_type(spr, center_dist);
|
165
|
168
|
}
|
166
|
169
|
}
|
167
|
170
|
|
|
@@ -202,6 +205,48 @@ enum OBJ_STATE obj_add(enum SPRITES sprite, int16_t off_x, int16_t off_y, int16_
|
202
|
205
|
return OBJ_ADDED;
|
203
|
206
|
}
|
204
|
207
|
|
|
208
|
+static uint8_t handle_shot_col(uint8_t shot, uint8_t orb, int32_t *score, uint8_t is_splash) {
|
|
209
|
+ if ((abs(objs[shot].off_x - objs[orb].off_x) <= SHOT_RANGE)
|
|
210
|
+ && (abs(objs[shot].off_y - objs[orb].off_y) <= SHOT_RANGE)) {
|
|
211
|
+ sample_play(SFX_EXPL_ORB);
|
|
212
|
+
|
|
213
|
+ objs[orb].active = 0;
|
|
214
|
+
|
|
215
|
+ obj_cnt[objs[shot].sprite]--;
|
|
216
|
+ obj_cnt[objs[orb].sprite]--;
|
|
217
|
+
|
|
218
|
+ objs[shot].sprite = SPR_EXPL;
|
|
219
|
+ objs[shot].travel = 0;
|
|
220
|
+ objs[shot].frame = 0;
|
|
221
|
+ objs[shot].frame_index = 0;
|
|
222
|
+ objs[shot].frame_count = 4;
|
|
223
|
+ objs[shot].frame_duration = 4;
|
|
224
|
+ obj_cnt[SPR_EXPL]++;
|
|
225
|
+
|
|
226
|
+ // move explosion to center of orb instead of shot
|
|
227
|
+ objs[shot].off_x = objs[orb].off_x;
|
|
228
|
+ objs[shot].off_y = objs[orb].off_y;
|
|
229
|
+
|
|
230
|
+ // also would look kinda cool with shot speed still applied?
|
|
231
|
+ objs[shot].spd_x = 0;
|
|
232
|
+ objs[shot].spd_y = 0;
|
|
233
|
+
|
|
234
|
+ if (!is_splash) {
|
|
235
|
+ obj_respawn_type(objs[orb].sprite, RESPAWN_DISTANCE);
|
|
236
|
+ }
|
|
237
|
+
|
|
238
|
+ if (objs[orb].sprite == SPR_LIGHT) {
|
|
239
|
+ (*score) += SCORE_LARGE;
|
|
240
|
+ } else {
|
|
241
|
+ (*score) -= SCORE_LARGE;
|
|
242
|
+ }
|
|
243
|
+
|
|
244
|
+ return 1;
|
|
245
|
+ }
|
|
246
|
+
|
|
247
|
+ return 0;
|
|
248
|
+}
|
|
249
|
+
|
205
|
250
|
int16_t obj_do(int16_t *spd_off_x, int16_t *spd_off_y, int32_t *score, uint8_t *hiwater, uint8_t is_splash) BANKED {
|
206
|
251
|
int16_t damage = 0;
|
207
|
252
|
|
|
@@ -250,8 +295,8 @@ int16_t obj_do(int16_t *spd_off_x, int16_t *spd_off_y, int32_t *score, uint8_t *
|
250
|
295
|
#ifdef DESPAWN_RANGE
|
251
|
296
|
if ((abs_off_x >= DESPAWN_RANGE) || (abs_off_y >= DESPAWN_RANGE)) {
|
252
|
297
|
objs[i].active = 0;
|
253
|
|
- obj_cnt[objs[i].sprite]--;
|
254
|
|
- obj_respawn(RESPAWN_DISTANCE);
|
|
298
|
+ obj_cnt[SPR_DARK]--;
|
|
299
|
+ obj_respawn_type(SPR_DARK, RESPAWN_DISTANCE);
|
255
|
300
|
}
|
256
|
301
|
#endif // DESPAWN_RANGE
|
257
|
302
|
|
|
@@ -271,14 +316,26 @@ int16_t obj_do(int16_t *spd_off_x, int16_t *spd_off_y, int32_t *score, uint8_t *
|
271
|
316
|
if ((abs_off_x <= DAMAGE_RANGE) && (abs_off_y <= DAMAGE_RANGE)) {
|
272
|
317
|
damage += DAMAGE_INC;
|
273
|
318
|
}
|
|
319
|
+
|
|
320
|
+#ifndef CHECK_COL_AT_SHOTS
|
|
321
|
+ for (uint8_t shot = 0; shot < MAX_OBJ; shot++) {
|
|
322
|
+ if ((!objs[shot].active) || (objs[shot].sprite != SPR_SHOT)) {
|
|
323
|
+ continue;
|
|
324
|
+ }
|
|
325
|
+
|
|
326
|
+ if (handle_shot_col(shot, i, score, is_splash)) {
|
|
327
|
+ break;
|
|
328
|
+ }
|
|
329
|
+ }
|
|
330
|
+#endif // ! CHECK_COL_AT_SHOTS
|
274
|
331
|
break;
|
275
|
332
|
|
276
|
333
|
case SPR_LIGHT:
|
277
|
334
|
#ifdef DESPAWN_RANGE
|
278
|
335
|
if ((abs_off_x >= DESPAWN_RANGE) || (abs_off_y >= DESPAWN_RANGE)) {
|
279
|
336
|
objs[i].active = 0;
|
280
|
|
- obj_cnt[objs[i].sprite]--;
|
281
|
|
- obj_respawn(RESPAWN_DISTANCE);
|
|
337
|
+ obj_cnt[SPR_LIGHT]--;
|
|
338
|
+ obj_respawn_type(SPR_LIGHT, RESPAWN_DISTANCE);
|
282
|
339
|
}
|
283
|
340
|
#endif // DESPAWN_RANGE
|
284
|
341
|
|
|
@@ -298,22 +355,34 @@ int16_t obj_do(int16_t *spd_off_x, int16_t *spd_off_y, int32_t *score, uint8_t *
|
298
|
355
|
if ((abs_off_x <= HEALTH_RANGE) && (abs_off_y <= HEALTH_RANGE)) {
|
299
|
356
|
damage -= HEALTH_INC;
|
300
|
357
|
}
|
|
358
|
+
|
|
359
|
+#ifndef CHECK_COL_AT_SHOTS
|
|
360
|
+ for (uint8_t shot = 0; shot < MAX_OBJ; shot++) {
|
|
361
|
+ if ((!objs[shot].active) || (objs[shot].sprite != SPR_SHOT)) {
|
|
362
|
+ continue;
|
|
363
|
+ }
|
|
364
|
+
|
|
365
|
+ if (handle_shot_col(shot, i, score, is_splash)) {
|
|
366
|
+ break;
|
|
367
|
+ }
|
|
368
|
+ }
|
|
369
|
+#endif // ! CHECK_COL_AT_SHOTS
|
301
|
370
|
break;
|
302
|
371
|
|
303
|
372
|
case SPR_SHOT_DARK:
|
304
|
373
|
#ifdef DESPAWN_RANGE
|
305
|
374
|
if ((abs_off_x >= DESPAWN_RANGE) || (abs_off_y >= DESPAWN_RANGE)) {
|
306
|
375
|
objs[i].active = 0;
|
307
|
|
- obj_cnt[objs[i].sprite]--;
|
308
|
|
- obj_respawn(RESPAWN_DISTANCE);
|
|
376
|
+ obj_cnt[SPR_SHOT_DARK]--;
|
|
377
|
+ obj_respawn_type(SPR_SHOT_DARK, RESPAWN_DISTANCE);
|
309
|
378
|
}
|
310
|
379
|
#endif // DESPAWN_RANGE
|
311
|
380
|
|
312
|
381
|
if ((abs_off_x <= PICKUP_SMALL_RANGE) && (abs_off_y <= PICKUP_SMALL_RANGE)) {
|
313
|
382
|
(*score) -= SCORE_SMALL;
|
314
|
383
|
objs[i].active = 0;
|
315
|
|
- obj_cnt[objs[i].sprite]--;
|
316
|
|
- obj_respawn(RESPAWN_DISTANCE);
|
|
384
|
+ obj_cnt[SPR_SHOT_DARK]--;
|
|
385
|
+ obj_respawn_type(SPR_SHOT_DARK, RESPAWN_DISTANCE);
|
317
|
386
|
}
|
318
|
387
|
break;
|
319
|
388
|
|
|
@@ -321,64 +390,33 @@ int16_t obj_do(int16_t *spd_off_x, int16_t *spd_off_y, int32_t *score, uint8_t *
|
321
|
390
|
#ifdef DESPAWN_RANGE
|
322
|
391
|
if ((abs_off_x >= DESPAWN_RANGE) || (abs_off_y >= DESPAWN_RANGE)) {
|
323
|
392
|
objs[i].active = 0;
|
324
|
|
- obj_cnt[objs[i].sprite]--;
|
325
|
|
- obj_respawn(RESPAWN_DISTANCE);
|
|
393
|
+ obj_cnt[SPR_SHOT_LIGHT]--;
|
|
394
|
+ obj_respawn_type(SPR_SHOT_LIGHT, RESPAWN_DISTANCE);
|
326
|
395
|
}
|
327
|
396
|
#endif // DESPAWN_RANGE
|
328
|
397
|
|
329
|
398
|
if ((abs_off_x <= PICKUP_SMALL_RANGE) && (abs_off_y <= PICKUP_SMALL_RANGE)) {
|
330
|
399
|
(*score) += SCORE_SMALL;
|
331
|
400
|
objs[i].active = 0;
|
332
|
|
- obj_cnt[objs[i].sprite]--;
|
333
|
|
- obj_respawn(RESPAWN_DISTANCE);
|
|
401
|
+ obj_cnt[SPR_SHOT_LIGHT]--;
|
|
402
|
+ obj_respawn_type(SPR_SHOT_LIGHT, RESPAWN_DISTANCE);
|
334
|
403
|
}
|
335
|
404
|
break;
|
336
|
405
|
|
|
406
|
+#ifdef CHECK_COL_AT_SHOTS
|
337
|
407
|
case SPR_SHOT:
|
338
|
|
- for (uint8_t j = 0; j < MAX_OBJ; j++) {
|
339
|
|
- if ((!objs[j].active) || ((objs[j].sprite != SPR_LIGHT) && (objs[j].sprite != SPR_DARK))) {
|
|
408
|
+ for (uint8_t orb = 0; orb < MAX_OBJ; orb++) {
|
|
409
|
+ if ((!objs[orb].active)
|
|
410
|
+ || ((objs[orb].sprite != SPR_LIGHT) && (objs[orb].sprite != SPR_DARK))) {
|
340
|
411
|
continue;
|
341
|
412
|
}
|
342
|
413
|
|
343
|
|
- if ((abs(objs[i].off_x - objs[j].off_x) <= SHOT_RANGE)
|
344
|
|
- && (abs(objs[i].off_y - objs[j].off_y) <= SHOT_RANGE)) {
|
345
|
|
- sample_play(SFX_EXPL_ORB);
|
346
|
|
-
|
347
|
|
- objs[j].active = 0;
|
348
|
|
-
|
349
|
|
- obj_cnt[objs[i].sprite]--;
|
350
|
|
- obj_cnt[objs[j].sprite]--;
|
351
|
|
-
|
352
|
|
- objs[i].sprite = SPR_EXPL;
|
353
|
|
- objs[i].travel = 0;
|
354
|
|
- objs[i].frame = 0;
|
355
|
|
- objs[i].frame_index = 0;
|
356
|
|
- objs[i].frame_count = 4;
|
357
|
|
- objs[i].frame_duration = 4;
|
358
|
|
- obj_cnt[SPR_EXPL]++;
|
359
|
|
-
|
360
|
|
- // move explosion to center of orb instead of shot
|
361
|
|
- objs[i].off_x = objs[j].off_x;
|
362
|
|
- objs[i].off_y = objs[j].off_y;
|
363
|
|
-
|
364
|
|
- // also would look kinda cool with shot speed still applied?
|
365
|
|
- objs[i].spd_x = 0;
|
366
|
|
- objs[i].spd_y = 0;
|
367
|
|
-
|
368
|
|
- if (!is_splash) {
|
369
|
|
- obj_respawn(RESPAWN_DISTANCE);
|
370
|
|
- }
|
371
|
|
-
|
372
|
|
- if (objs[j].sprite == SPR_LIGHT) {
|
373
|
|
- (*score) += SCORE_LARGE;
|
374
|
|
- } else {
|
375
|
|
- (*score) -= SCORE_LARGE;
|
376
|
|
- }
|
377
|
|
-
|
|
414
|
+ if (handle_shot_col(i, orb, score, is_splash)) {
|
378
|
415
|
break;
|
379
|
416
|
}
|
380
|
417
|
}
|
381
|
418
|
break;
|
|
419
|
+#endif // CHECK_COL_AT_SHOTS
|
382
|
420
|
|
383
|
421
|
default:
|
384
|
422
|
break;
|