Browse Source

show explosion when orbs are shot

Thomas B 1 month ago
parent
commit
9f9660fdb7
2 changed files with 40 additions and 3 deletions
  1. 39
    2
      src/obj.c
  2. 1
    1
      src/sprite_data.c

+ 39
- 2
src/obj.c View File

88
     int16_t spd_x;
88
     int16_t spd_x;
89
     int16_t spd_y;
89
     int16_t spd_y;
90
     uint8_t travel;
90
     uint8_t travel;
91
+    uint8_t frame;
92
+    uint8_t frame_index;
93
+    uint8_t frame_count;
94
+    uint8_t frame_duration;
91
 };
95
 };
92
 
96
 
93
 static struct obj objs[MAX_OBJ];
97
 static struct obj objs[MAX_OBJ];
190
     objs[next].spd_x = spd_x;
194
     objs[next].spd_x = spd_x;
191
     objs[next].spd_y = spd_y;
195
     objs[next].spd_y = spd_y;
192
     objs[next].travel = 0;
196
     objs[next].travel = 0;
197
+    objs[next].frame = 0;
198
+    objs[next].frame_index = 0;
199
+    objs[next].frame_count = 1;
200
+    objs[next].frame_duration = 0;
193
 
201
 
194
     return OBJ_ADDED;
202
     return OBJ_ADDED;
195
 }
203
 }
336
                             && (abs(objs[i].off_y - objs[j].off_y) <= SHOT_RANGE)) {
344
                             && (abs(objs[i].off_y - objs[j].off_y) <= SHOT_RANGE)) {
337
                         sample_play_explosion_orbs();
345
                         sample_play_explosion_orbs();
338
 
346
 
339
-                        objs[i].active = 0;
340
                         objs[j].active = 0;
347
                         objs[j].active = 0;
341
 
348
 
342
                         obj_cnt[objs[i].sprite]--;
349
                         obj_cnt[objs[i].sprite]--;
343
                         obj_cnt[objs[j].sprite]--;
350
                         obj_cnt[objs[j].sprite]--;
344
 
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
+
345
                         if (!is_splash) {
368
                         if (!is_splash) {
346
                             obj_respawn(RESPAWN_DISTANCE);
369
                             obj_respawn(RESPAWN_DISTANCE);
347
                         }
370
                         }
365
             continue;
388
             continue;
366
         }
389
         }
367
 
390
 
368
-        spr_draw(objs[i].sprite, FLIP_NONE, objs[i].off_x >> POS_SCALE_OBJS, objs[i].off_y >> POS_SCALE_OBJS, 0, hiwater);
391
+        spr_draw(objs[i].sprite, FLIP_NONE, objs[i].off_x >> POS_SCALE_OBJS, objs[i].off_y >> POS_SCALE_OBJS, objs[i].frame_index, hiwater);
392
+
393
+        objs[i].frame++;
394
+        if (objs[i].frame >= objs[i].frame_duration) {
395
+            objs[i].frame = 0;
396
+            objs[i].frame_index++;
397
+            if (objs[i].frame_index >= objs[i].frame_count) {
398
+                objs[i].frame_index = 0;
399
+
400
+                if (objs[i].sprite == SPR_EXPL) {
401
+                    objs[i].active = 0;
402
+                    obj_cnt[SPR_EXPL]--;
403
+                }
404
+            }
405
+        }
369
     }
406
     }
370
 
407
 
371
     return damage;
408
     return damage;

+ 1
- 1
src/sprite_data.c View File

148
         .ti = expl_spr16_tiles,
148
         .ti = expl_spr16_tiles,
149
         .pa = expl_spr16_palettes,
149
         .pa = expl_spr16_palettes,
150
         .pa_n = expl_spr16_PALETTE_COUNT,
150
         .pa_n = expl_spr16_PALETTE_COUNT,
151
-        .pa_i = OAMF_CGB_PAL0 | PALETTE_DYNAMIC_LOAD,
151
+        .pa_i = OAMF_CGB_PAL7 | PALETTE_DYNAMIC_LOAD_IP,
152
         .cnt = expl_spr16_TILE_COUNT,
152
         .cnt = expl_spr16_TILE_COUNT,
153
         .off = TILE_NUM_START,
153
         .off = TILE_NUM_START,
154
         .bank = BANK(expl_spr16),
154
         .bank = BANK(expl_spr16),

Loading…
Cancel
Save