|
@@ -131,12 +131,30 @@ enum OBJ_STATE obj_add(enum SPRITES sprite, int16_t off_x, int16_t off_y, int16_
|
131
|
131
|
|
132
|
132
|
int16_t obj_act(int16_t *spd_off_x, int16_t *spd_off_y, int32_t *score) NONBANKED {
|
133
|
133
|
int16_t damage = 0;
|
|
134
|
+ int16_t spd_x = *spd_off_x;
|
|
135
|
+ int16_t spd_y = *spd_off_y;
|
134
|
136
|
|
135
|
137
|
for (uint8_t i = 0; i < MAX_OBJ; i++) {
|
136
|
138
|
if (!objs[i].active) {
|
137
|
139
|
continue;
|
138
|
140
|
}
|
139
|
141
|
|
|
142
|
+ // move objects by their speed and compensate for movement of the background / ship
|
|
143
|
+ objs[i].off_x = (objs[i].off_x + objs[i].spd_x - spd_x) & POS_MASK_OBJS;
|
|
144
|
+ objs[i].off_y = (objs[i].off_y + objs[i].spd_y - spd_y) & POS_MASK_OBJS;
|
|
145
|
+
|
|
146
|
+ // only update travel time if we're actually moving
|
|
147
|
+ if ((objs[i].spd_x != 0) || (objs[i].spd_y != 0)) {
|
|
148
|
+ objs[i].travel += 1;
|
|
149
|
+ }
|
|
150
|
+
|
|
151
|
+ // remove objects that have traveled for too long
|
|
152
|
+ if (objs[i].travel >= MAX_TRAVEL) {
|
|
153
|
+ objs[i].active = 0;
|
|
154
|
+ continue;
|
|
155
|
+ }
|
|
156
|
+
|
|
157
|
+ // handle collission
|
140
|
158
|
switch (objs[i].sprite) {
|
141
|
159
|
case SPR_DARK:
|
142
|
160
|
if ((abs(objs[i].off_x) <= GRAVITY_RANGE) && (abs(objs[i].off_y) <= GRAVITY_RANGE)) {
|
|
@@ -220,26 +238,12 @@ int16_t obj_act(int16_t *spd_off_x, int16_t *spd_off_y, int32_t *score) NONBANKE
|
220
|
238
|
return damage;
|
221
|
239
|
}
|
222
|
240
|
|
223
|
|
-void obj_draw(int16_t spd_x, int16_t spd_y, uint8_t *hiwater) NONBANKED {
|
|
241
|
+void obj_draw(uint8_t *hiwater) NONBANKED {
|
224
|
242
|
for (uint8_t i = 0; i < MAX_OBJ; i++) {
|
225
|
243
|
if (!objs[i].active) {
|
226
|
244
|
continue;
|
227
|
245
|
}
|
228
|
246
|
|
229
|
|
- // move objects by their speed and compensate for movement of the background / ship
|
230
|
|
- objs[i].off_x += objs[i].spd_x - spd_x;
|
231
|
|
- objs[i].off_y += objs[i].spd_y - spd_y;
|
232
|
|
-
|
233
|
|
- // only update travel time if we're actually moving
|
234
|
|
- if ((objs[i].spd_x != 0) || (objs[i].spd_y != 0)) {
|
235
|
|
- objs[i].travel += 1;
|
236
|
|
- }
|
237
|
|
-
|
238
|
|
- // remove objects that have traveled for too long
|
239
|
|
- if (objs[i].travel >= MAX_TRAVEL) {
|
240
|
|
- objs[i].active = 0;
|
241
|
|
- }
|
242
|
|
-
|
243
|
247
|
spr_draw(objs[i].sprite, FLIP_NONE, objs[i].off_x >> POS_SCALE_OBJS, objs[i].off_y >> POS_SCALE_OBJS, 0, hiwater);
|
244
|
248
|
}
|
245
|
249
|
}
|