Sinnvolleres Spawn- und Bewegungsverhalten.
[hackover2013-badge-firmware.git] / badge / jumpnrun / enemies.c
1 #include "enemies.h"
2
3 #include "collision.h"
4 #include "game_state.h"
5 #include "tiles.h"
6 #include "jumpnrun.h"
7 #include "moveable.h"
8 #include "render.h"
9
10 static badge_sprite const anim_cat[] = {
11 { 8, 5, (uint8_t const *) "\xc7\x3f\xce\x38\x11" },
12 { 8, 5, (uint8_t const *) "\xd7\x7d\xc6\x19\x25" }
13 };
14
15 static badge_sprite const anim_mushroom[] = {
16 { 7, 7, (uint8_t const *) "\x10\x0c\x9f\xcf\xc7\x40" },
17 { 7, 7, (uint8_t const *) "\x20\x18\x1e\x8f\x87\x81" },
18 { 7, 7, (uint8_t const *) "\x10\x0c\x9f\xcf\xc7\x40" },
19 { 7, 7, (uint8_t const *) "\x08\x86\xdf\xef\x67\x20" },
20 { 7, 7, (uint8_t const *) "\x04\xc3\xef\xf7\x33\x10" },
21 { 7, 7, (uint8_t const *) "\x04\xc3\xe7\xf3\x31\x10" }
22 };
23
24 static badge_sprite const anim_bunny[] = {
25 { 7, 5, (uint8_t const *) "\x60\x30\xbe\x31\x02" },
26 { 7, 5, (uint8_t const *) "\x42\x30\xbe\x31\x01" },
27 { 7, 5, (uint8_t const *) "\x42\x30\xae\x35\x01" },
28 { 7, 5, (uint8_t const *) "\x60\x30\xae\x35\x02" },
29 { 7, 5, (uint8_t const *) "\x60\x30\xbe\x31\x01" }
30 };
31
32 static badge_sprite const anim_snake[] = {
33 { 10, 6, (uint8_t const *) "\x10\x86\x83\x30\x04\x83\xa2\x07" },
34 { 10, 6, (uint8_t const *) "\x10\x86\x83\x20\x0c\xc1\xa2\x07" },
35 { 10, 6, (uint8_t const *) "\x10\x86\x83\x20\x08\x82\xe0\x07" },
36 { 10, 6, (uint8_t const *) "\x10\x86\x83\x20\x08\x86\xe1\x07" }
37 };
38
39 static badge_sprite const anim_spiral[] = {
40 { 10, 10, (uint8_t const *) "\xff\x07\xd8\x6f\xa1\xb5\xf6\x1a\xe8\xbf\x00\xfe\x0f" },
41 { 10, 10, (uint8_t const *) "\xff\x07\xd8\x6f\xa1\xb5\xd6\xda\x69\xb0\x7f\x02\x0c" },
42 { 10, 10, (uint8_t const *) "\xff\x07\xd8\x6f\xa1\xb5\xd6\x5a\x6a\xaf\x81\xfe\x0b" },
43 { 10, 10, (uint8_t const *) "\xff\x07\xd8\x4f\x61\x35\xd5\x55\x54\x5f\x01\xfd\x07" },
44 { 10, 10, (uint8_t const *) "\xff\x07\xd0\x7f\x81\xf5\xd6\x5a\x68\xbf\x01\xfe\x0f" },
45 { 10, 10, (uint8_t const *) "\x03\xe4\xdf\x60\xb9\xb5\xd6\x5a\x68\xbf\x01\xfe\x0f" },
46 { 10, 10, (uint8_t const *) "\xfd\x17\x58\x6f\xa5\xb5\xd6\x5a\x68\xbf\x01\xfe\x0f" },
47 { 10, 10, (uint8_t const *) "\xfe\x0b\xa8\xaf\xa2\xba\xca\x6a\x28\xbf\x01\xfe\x0f" }
48 };
49
50 static badge_sprite const anim_rotor[] = {
51 { 9, 9, (uint8_t const *) "\x00\x00\x00\x00\xf0\xe1\x42\x0c\x18\x70\x00" },
52 { 9, 9, (uint8_t const *) "\x1c\x30\x60\x80\xf0\xe1\x40\x00\x00\x00\x00" },
53 { 9, 9, (uint8_t const *) "\x1c\x30\x60\x84\x0e\x1f\x00\x00\x00\x00\x00" },
54 { 9, 9, (uint8_t const *) "\x00\x00\x00\x04\x0e\x1f\x02\x0c\x18\x70\x00" }
55 };
56
57 static badge_sprite const anim_dog[] = {
58 { 8, 5, (uint8_t const *) "\xc1\xf8\xc6\xb8\x08" },
59 { 8, 5, (uint8_t const *) "\xc1\xba\xce\x99\x0c" },
60 { 8, 5, (uint8_t const *) "\xc1\xf8\xc6\xb8\x10" },
61 { 8, 5, (uint8_t const *) "\xc1\xf8\xc6\xb8\x20" }
62 };
63
64 static badge_sprite const anim_giraffe[] = {
65 { 8, 10, (uint8_t const *) "\x00\x10\x60\x80\xff\xc1\x00\x03\x3c\x08" },
66 { 8, 10, (uint8_t const *) "\x00\x10\x60\xa0\x7f\xc1\x00\x03\x1c\x88" },
67 { 9, 10, (uint8_t const *) "\x00\x10\x68\x90\x3f\xc1\x00\x03\x0c\x48\x00\x02" },
68 { 8, 10, (uint8_t const *) "\x00\x10\x60\xb0\x3f\xc1\x00\x03\x0c\xc8" },
69 { 8, 10, (uint8_t const *) "\x08\x30\xc0\x81\xfc\xc0\x00\x03\x3c\x08" },
70 { 8, 10, (uint8_t const *) "\x00\x10\x60\x80\xff\xc1\x00\x03\x3c\x08" }
71 };
72
73 static badge_sprite const anim_bird[] = {
74 { 9, 7, (uint8_t const *) "\x10\x0c\x05\xf7\x4a\xa9\x58\x10" },
75 { 9, 7, (uint8_t const *) "\x10\x0c\x05\x87\x47\xa2\x70\x10" }
76 /*
77 { 10, 8, (uint8_t const *) "\x10\x10\x18\x14\x38\x2e\x29\x29\x2e\x10" },
78 { 10, 8, (uint8_t const *) "\x10\x10\x18\x14\x38\x78\xa8\xa8\x78\x10" }
79 */
80 };
81
82 static void enemy_animation_advance(jumpnrun_enemy *enemy) {
83 ++enemy->base.tick_minor;
84 if(enemy->base.tick_minor == enemy->type->animation_ticks_per_frame) {
85 enemy->base.tick_minor = 0;
86
87 ++enemy->base.anim_frame;
88 if(enemy->base.anim_frame >= enemy->type->animation_length) {
89 enemy->base.anim_frame = 0;
90 }
91 }
92 }
93
94 static void enemy_spawn(jumpnrun_enemy *self) {
95 // enemy unspawned, available and in spawn zone.
96 self->base.flags = JUMPNRUN_ENEMY_SPAWNED | JUMPNRUN_ENEMY_UNAVAILABLE;
97 self->base.anim_frame = 0;
98 self->base.tick_minor = 0;
99 self->base.jumpable_frames = 0;
100 }
101
102 void jumpnrun_enemy_despawn(jumpnrun_enemy *self) {
103 // Despawned enemies are reset to their spawn position, so enemy_in_spawn_area will determine whether the spawn point is in the spawn area.
104 self->base.flags &= ~(JUMPNRUN_ENEMY_SPAWNED | JUMPNRUN_ENEMY_MOVING);
105 self->base.hitbox = rectangle_new(self->spawn_pos, self->type->hitbox.extent);
106 self->base.inertia = self->type->spawn_inertia;
107 }
108
109 void jumpnrun_enemy_reset (jumpnrun_enemy *self) {
110 jumpnrun_enemy_despawn(self);
111 self->base.flags &= ~JUMPNRUN_ENEMY_UNAVAILABLE;
112 }
113
114 static void enemy_bounce(jumpnrun_enemy *self) {
115 self->base.inertia.x = fixed_point_neg(self->base.inertia.x);
116 }
117
118 static inline vec2d enemy_pos_hitbox (jumpnrun_enemy const *self) { return self->base.hitbox.pos; }
119 static inline vec2d enemy_pos_display(jumpnrun_enemy const *self) { return vec2d_sub(enemy_pos_hitbox(self), self->type->hitbox.pos); }
120 static inline vec2d enemy_pos_desired(jumpnrun_enemy const *self) { return vec2d_add(enemy_pos_hitbox(self), self->base.inertia); }
121
122 static inline void enemy_move_to(jumpnrun_enemy *self, vec2d new_pos) {
123 rectangle_move_to(&self->base.hitbox, new_pos);
124 }
125
126 static inline bool enemy_in_area(jumpnrun_enemy const *self, jumpnrun_game_state *state, int margin) {
127 return
128 fixed_point_gt(rectangle_left (enemy_hitbox(self)), FIXED_INT(jumpnrun_screen_left (state) - margin)) &&
129 fixed_point_lt(rectangle_right(enemy_hitbox(self)), FIXED_INT(jumpnrun_screen_right(state) + margin));
130 }
131
132 static inline bool enemy_on_screen(jumpnrun_enemy const *self, jumpnrun_game_state *state) {
133 return enemy_in_area(self, state, self->type->animation_frames[self->base.anim_frame].width);
134 }
135
136 static inline bool enemy_in_spawn_area(jumpnrun_enemy const *self, jumpnrun_game_state *state) {
137 return enemy_in_area(self, state, JUMPNRUN_MAX_SPAWN_MARGIN);
138 }
139
140 void jumpnrun_process_enemy(jumpnrun_enemy *self,
141 badge_framebuffer *fb,
142 struct jumpnrun_game_state *state,
143 struct jumpnrun_level *lv,
144 struct jumpnrun_tile_range const *visible_tiles,
145 vec2d *player_inertia_mod) {
146 // Despawned enemies are reset to their spawn position, so enemy_in_spawn_area will determine whether the spawn point is in the spawn area.
147 if(self->base.flags & JUMPNRUN_ENEMY_SPAWNED) {
148 if(!enemy_in_spawn_area(self, state) || fixed_point_gt(rectangle_top (enemy_hitbox(self)), FIXED_INT(BADGE_DISPLAY_HEIGHT))) {
149 jumpnrun_enemy_despawn(self);
150 } else {
151 if((self->base.flags & JUMPNRUN_ENEMY_MOVING) || enemy_on_screen(self, state)) {
152 self->base.flags |= JUMPNRUN_ENEMY_MOVING;
153
154 self->type->move_tick(self, state, lv, visible_tiles, player_inertia_mod);
155 self->type->collision_shots(self, state);
156 if (fixed_point_lt(self->base.inertia.x, FIXED_INT(0))) { self->base.flags &= ~JUMPNRUN_MOVEABLE_MIRRORED; }
157 else if(fixed_point_ne(self->base.inertia.x, FIXED_INT(0))) { self->base.flags |= JUMPNRUN_MOVEABLE_MIRRORED; }
158 }
159
160 if(fb) {
161 jumpnrun_render_enemy(fb, state, self);
162 }
163 }
164 } else if(self->base.flags & JUMPNRUN_ENEMY_UNAVAILABLE) {
165 if(!enemy_in_spawn_area(self, state)) {
166 self->base.flags &= ~JUMPNRUN_ENEMY_UNAVAILABLE;
167 }
168 } else if(enemy_in_spawn_area(self, state)) {
169 // enemy unspawned, available and in spawn zone.
170 enemy_spawn(self);
171 }
172 }
173
174 void enemy_collision_tiles_bounce_horiz(jumpnrun_enemy *self,
175 vec2d *desired_position,
176 jumpnrun_level *lv,
177 jumpnrun_tile_range const *visible_tiles) {
178 vec2d inertia_mod = self->base.inertia;
179
180 bool killed = collisions_tiles_displace(desired_position,
181 &self->base,
182 lv,
183 visible_tiles,
184 &inertia_mod);
185
186 if(killed) {
187 jumpnrun_enemy_despawn(self);
188 } else if(fixed_point_ne(inertia_mod.x, self->base.inertia.x)) {
189 enemy_bounce(self);
190 }
191 }
192
193 void enemy_collision_player_deadly(struct jumpnrun_enemy *self,
194 struct jumpnrun_game_state *state,
195 vec2d *player_inertia_mod) {
196 (void) player_inertia_mod;
197
198 if(rectangle_intersect(enemy_hitbox(self), &state->player.base.hitbox)) {
199 state->player.base.flags |= JUMPNRUN_PLAYER_DEAD;
200 }
201 }
202
203 void enemy_collision_player_jumpable(jumpnrun_enemy *self,
204 jumpnrun_game_state *state,
205 vec2d *player_inertia_mod)
206 {
207 if(rectangle_intersect(enemy_hitbox(self), &state->player.base.hitbox)) {
208 if(fixed_point_lt(rectangle_top(&state->player.base.hitbox), rectangle_top(enemy_hitbox(self))) &&
209 fixed_point_gt(state->player.base.inertia.y, FIXED_INT(0)))
210 {
211 jumpnrun_enemy_despawn(self);
212 player_inertia_mod->y = FIXED_POINT(0, -250);
213 state->player.base.jumpable_frames = 12;
214 } else {
215 state->player.base.flags |= JUMPNRUN_PLAYER_DEAD;
216 }
217 }
218 }
219
220 void enemy_collision_tiles_pass_through(struct jumpnrun_enemy *self,
221 vec2d *desired_position,
222 struct jumpnrun_level *lv,
223 struct jumpnrun_tile_range const *visible_tiles) {
224 (void) self;
225 (void) desired_position;
226 (void) lv;
227 (void) visible_tiles;
228 }
229
230 void enemy_collision_shots_die(struct jumpnrun_enemy *self,
231 struct jumpnrun_game_state *state) {
232 for(uint8_t i = 0; i < JUMPNRUN_MAX_SHOTS; ++i) {
233 jumpnrun_shot *shot = &state->shots[i];
234
235 if(jumpnrun_shot_spawned(shot)) {
236 if(rectangle_intersect(enemy_hitbox(self), &shot->current_box)) {
237 self->base.flags &= ~JUMPNRUN_ENEMY_SPAWNED;
238 jumpnrun_shot_despawn(shot);
239 }
240 }
241 }
242 }
243
244 void enemy_collision_shots_bounce(struct jumpnrun_enemy *self,
245 struct jumpnrun_game_state *state) {
246 for(uint8_t i = 0; i < JUMPNRUN_MAX_SHOTS; ++i) {
247 jumpnrun_shot *shot = &state->shots[i];
248
249 if(jumpnrun_shot_spawned(shot)) {
250 if(rectangle_intersect(enemy_hitbox(self), &shot->current_box)) {
251 if(fixed_point_gt(shot->inertia.x, FIXED_INT(0))) {
252 rectangle_move_to_x(&shot->current_box, fixed_point_sub(rectangle_left(enemy_hitbox(self)), rectangle_width(&shot->current_box)));
253 } else {
254 rectangle_move_to_x(&shot->current_box, rectangle_right(enemy_hitbox(self)));
255 }
256
257 shot->inertia.x = fixed_point_neg(shot->inertia.x);
258 }
259 }
260 }
261 }
262
263 void enemy_collision_shots_dontcare(struct jumpnrun_enemy *self,
264 struct jumpnrun_game_state *state) {
265 (void) self;
266 (void) state;
267 }
268
269 static void enemy_tick_common(jumpnrun_enemy *self,
270 jumpnrun_game_state *state,
271 jumpnrun_level *lv,
272 jumpnrun_tile_range const *visible_tiles,
273 vec2d *player_inertia_mod) {
274 vec2d new_pos = enemy_pos_desired(self);
275 self->type->collision_tiles (self, &new_pos, lv, visible_tiles);
276 self->type->collision_player(self, state, player_inertia_mod);
277 enemy_move_to(self, new_pos);
278 }
279
280 void enemy_tick_straight_ahead(jumpnrun_enemy *self,
281 jumpnrun_game_state *state,
282 jumpnrun_level *lv,
283 jumpnrun_tile_range const *visible_tiles,
284 vec2d *player_inertia_mod) {
285 jumpnrun_passive_movement(&self->base.inertia);
286 enemy_tick_common(self, state, lv, visible_tiles, player_inertia_mod);
287 enemy_animation_advance(self);
288 }
289
290 void enemy_tick_straight_follow(jumpnrun_enemy *self,
291 jumpnrun_game_state *state,
292 jumpnrun_level *lv,
293 jumpnrun_tile_range const *visible_tiles,
294 vec2d *player_inertia_mod) {
295 jumpnrun_passive_movement(&self->base.inertia);
296 enemy_tick_common(self, state, lv, visible_tiles, player_inertia_mod);
297
298 if(fixed_point_lt(rectangle_right(&state->player.base.hitbox), rectangle_left(enemy_hitbox(self)))) {
299 self->base.inertia.x = self->type->spawn_inertia.x;
300 } else if(fixed_point_gt(rectangle_left(&state->player.base.hitbox), rectangle_right(enemy_hitbox(self)))) {
301 self->base.inertia.x = fixed_point_neg(self->type->spawn_inertia.x);
302 }
303
304 enemy_animation_advance(self);
305 }
306
307 void enemy_tick_swing_up_and_down(struct jumpnrun_enemy *self,
308 struct jumpnrun_game_state *state,
309 struct jumpnrun_level *lv,
310 struct jumpnrun_tile_range const *visible_tiles,
311 vec2d *player_inertia_mod) {
312 enemy_tick_common(self, state, lv, visible_tiles, player_inertia_mod);
313
314 self->base.inertia.y =
315 fixed_point_add(fixed_point_add(self->base.inertia.y,
316 fixed_point_div(self->type->spawn_inertia.y, FIXED_INT(3))),
317 fixed_point_mul(FIXED_POINT(0, 5),
318 fixed_point_sub(self->spawn_pos.y,
319 enemy_pos_display(self).y)));
320
321 enemy_animation_advance(self);
322 }
323
324 void enemy_tick_stationary(struct jumpnrun_enemy *self,
325 struct jumpnrun_game_state *state,
326 struct jumpnrun_level *lv,
327 struct jumpnrun_tile_range const *visible_tiles,
328 vec2d *player_inertia_mod) {
329 self->type->collision_tiles(self, &self->base.hitbox.pos, lv, visible_tiles);
330 self->type->collision_player(self, state, player_inertia_mod);
331
332 enemy_animation_advance(self);
333 }
334
335 void enemy_tick_jumper(jumpnrun_enemy *self,
336 jumpnrun_game_state *state,
337 jumpnrun_level *lv,
338 jumpnrun_tile_range const *visible_tiles,
339 vec2d *player_inertia_mod) {
340 jumpnrun_passive_movement(&self->base.inertia);
341 enemy_tick_common(self, state, lv, visible_tiles, player_inertia_mod);
342
343 if(jumpnrun_moveable_touching_ground(&self->base)) {
344 self->base.inertia.y = self->type->spawn_inertia.y;
345 }
346
347 enemy_animation_advance(self);
348 }
349
350 void enemy_tick_dog(jumpnrun_enemy *self,
351 jumpnrun_game_state *state,
352 jumpnrun_level *lv,
353 jumpnrun_tile_range const *visible_tiles,
354 vec2d *player_inertia_mod) {
355 jumpnrun_passive_movement(&self->base.inertia);
356 enemy_tick_common(self, state, lv, visible_tiles, player_inertia_mod);
357
358 if(self->base.tick_minor % self->type->animation_ticks_per_frame == 0) {
359 switch(self->base.tick_minor / self->type->animation_ticks_per_frame) {
360 case 12:
361 self->base.tick_minor = 0;
362 case 0:
363 case 2:
364 case 4:
365 case 6:
366 self->base.anim_frame = 0;
367 if(self->base.flags & JUMPNRUN_MOVEABLE_MIRRORED) {
368 self->base.inertia.x = fixed_point_neg(self->type->spawn_inertia.x);
369 } else {
370 self->base.inertia.x = self->type->spawn_inertia.x;
371 }
372
373 break;
374
375 case 1:
376 case 3:
377 case 5:
378 case 7:
379 self->base.anim_frame = 1;
380 if(self->base.flags & JUMPNRUN_MOVEABLE_MIRRORED) {
381 self->base.inertia.x = fixed_point_neg(self->type->spawn_inertia.x);
382 } else {
383 self->base.inertia.x = self->type->spawn_inertia.x;
384 }
385 break;
386
387 case 8:
388 case 10:
389 self->base.anim_frame = 2;
390 self->base.inertia.x = FIXED_INT(0);
391 break;
392
393 case 9:
394 case 11:
395 self->base.anim_frame = 3;
396 self->base.inertia.x = FIXED_INT(0);
397 break;
398 }
399 }
400
401 ++self->base.tick_minor;
402 }
403
404 void enemy_tick_giraffe(jumpnrun_enemy *self,
405 jumpnrun_game_state *state,
406 jumpnrun_level *lv,
407 jumpnrun_tile_range const *visible_tiles,
408 vec2d *player_inertia_mod) {
409 bool was_on_ground = jumpnrun_moveable_touching_ground(&self->base);
410
411 jumpnrun_passive_movement(&self->base.inertia);
412 enemy_tick_common(self, state, lv, visible_tiles, player_inertia_mod);
413
414 if(jumpnrun_moveable_touching_ground(&self->base)) {
415 if(was_on_ground) {
416 enemy_animation_advance(self);
417 if(self->base.anim_frame == 0) {
418 self->base.inertia = self->type->spawn_inertia;
419
420 if(fixed_point_gt(rectangle_mid_x(&state->player.base.hitbox), rectangle_mid_x(enemy_hitbox(self)))) {
421 self->base.inertia.x = fixed_point_neg(self->base.inertia.x);
422 }
423 }
424 } else {
425 self->base.tick_minor = 0;
426 self->base.anim_frame = 3;
427 self->base.inertia.x = FIXED_INT(0);
428 }
429 } else if(was_on_ground) {
430 self->base.tick_minor = 0;
431 self->base.anim_frame = 1;
432 } else if(self->base.anim_frame == 1) {
433 enemy_animation_advance(self);
434 }
435
436 ++self->base.tick_minor;
437 }
438
439 void enemy_tick_fly_straight(struct jumpnrun_enemy *self,
440 struct jumpnrun_game_state *state,
441 struct jumpnrun_level *lv,
442 struct jumpnrun_tile_range const *visible_tiles,
443 vec2d *player_inertia_mod) {
444 enemy_tick_common(self, state, lv, visible_tiles, player_inertia_mod);
445 enemy_animation_advance(self);
446 }
447
448 void enemy_tick_fly_straight_and_dip(struct jumpnrun_enemy *self,
449 struct jumpnrun_game_state *state,
450 struct jumpnrun_level *lv,
451 struct jumpnrun_tile_range const *visible_tiles,
452 vec2d *player_inertia_mod) {
453 if(fixed_point_lt(fixed_point_abs(fixed_point_sub(enemy_pos_hitbox(self).x,
454 state->player.base.hitbox.pos.x)),
455 FIXED_INT(20))) {
456 self->base.flags |= JUMPNRUN_ENEMY_EVENT_TRIGGER1;
457 }
458
459 if(self->base.flags & JUMPNRUN_ENEMY_EVENT_TRIGGER1) {
460 self->base.inertia.y =
461 fixed_point_add(fixed_point_add(self->base.inertia.y,
462 fixed_point_div(self->type->spawn_inertia.y, FIXED_INT(3))),
463 fixed_point_mul(FIXED_POINT(0, 5),
464 fixed_point_sub(self->spawn_pos.y,
465 enemy_pos_hitbox(self).y)));
466 } else {
467 self->base.inertia.y = FIXED_INT(0);
468 }
469
470 enemy_tick_common(self, state, lv, visible_tiles, player_inertia_mod);
471 enemy_animation_advance(self);
472 }
473
474 jumpnrun_enemy_type const jumpnrun_enemy_type_data[JUMPNRUN_ENEMY_TYPE_COUNT] = {
475 {
476 .animation_ticks_per_frame = 18,
477 .animation_length = ARRAY_SIZE(anim_cat),
478 .animation_frames = anim_cat,
479 .hitbox = { { FIXED_INT_I(1), FIXED_INT_I(2) },
480 { FIXED_INT_I(6), FIXED_INT_I(3) } },
481 .spawn_inertia = { FIXED_POINT_I(0, -200), FIXED_INT_I(0) },
482 .collision_tiles = enemy_collision_tiles_bounce_horiz,
483 .collision_player = enemy_collision_player_jumpable,
484 .collision_shots = enemy_collision_shots_die,
485 .move_tick = enemy_tick_straight_ahead
486 }, {
487 .animation_ticks_per_frame = 12,
488 .animation_length = ARRAY_SIZE(anim_mushroom),
489 .animation_frames = anim_mushroom,
490 .hitbox = { { FIXED_INT_I(1), FIXED_INT_I(1) },
491 { FIXED_INT_I(5), FIXED_INT_I(6) } },
492 .spawn_inertia = { FIXED_POINT_I(0, -80), FIXED_INT_I(0) },
493 .collision_tiles = enemy_collision_tiles_bounce_horiz,
494 .collision_player = enemy_collision_player_jumpable,
495 .collision_shots = enemy_collision_shots_die,
496 .move_tick = enemy_tick_straight_follow
497 }, {
498 .animation_ticks_per_frame = 9,
499 .animation_length = ARRAY_SIZE(anim_bunny),
500 .animation_frames = anim_bunny,
501 .hitbox = { { FIXED_INT_I(1), FIXED_INT_I(2) },
502 { FIXED_INT_I(5), FIXED_INT_I(3) } },
503 .spawn_inertia = { FIXED_POINT_I(0, -80), FIXED_POINT_I(0, -800) },
504 .collision_tiles = enemy_collision_tiles_bounce_horiz,
505 .collision_player = enemy_collision_player_jumpable,
506 .collision_shots = enemy_collision_shots_die,
507 .move_tick = enemy_tick_jumper
508 }, {
509 .animation_ticks_per_frame = 6,
510 .animation_length = ARRAY_SIZE(anim_snake),
511 .animation_frames = anim_snake,
512 .hitbox = { { FIXED_INT_I(1), FIXED_INT_I(4) },
513 { FIXED_INT_I(8), FIXED_INT_I(2) } },
514 .spawn_inertia = { FIXED_POINT_I(0, -150), FIXED_INT_I(0) },
515 .collision_tiles = enemy_collision_tiles_bounce_horiz,
516 .collision_player = enemy_collision_player_jumpable,
517 .collision_shots = enemy_collision_shots_die,
518 .move_tick = enemy_tick_straight_ahead
519 }, {
520 .animation_ticks_per_frame = 6,
521 .animation_length = ARRAY_SIZE(anim_spiral),
522 .animation_frames = anim_spiral,
523 .hitbox = { { FIXED_INT_I(1), FIXED_INT_I(1) },
524 { FIXED_INT_I(8), FIXED_INT_I(8) } },
525 .spawn_inertia = { FIXED_INT_I(0), FIXED_POINT_I(0, -200) },
526 .collision_tiles = enemy_collision_tiles_pass_through,
527 .collision_player = enemy_collision_player_deadly,
528 .collision_shots = enemy_collision_shots_dontcare,
529 .move_tick = enemy_tick_swing_up_and_down
530 }, {
531 .animation_ticks_per_frame = 5,
532 .animation_length = ARRAY_SIZE(anim_rotor),
533 .animation_frames = anim_rotor,
534 .hitbox = { { FIXED_INT_I(1), FIXED_INT_I(1) },
535 { FIXED_INT_I(7), FIXED_INT_I(7) } },
536 .spawn_inertia = { FIXED_INT_I(0), FIXED_POINT_I(0, 0) },
537 .collision_tiles = enemy_collision_tiles_pass_through,
538 .collision_player = enemy_collision_player_deadly,
539 .collision_shots = enemy_collision_shots_dontcare,
540 .move_tick = enemy_tick_stationary
541 }, {
542 .animation_ticks_per_frame = 18,
543 .animation_length = ARRAY_SIZE(anim_dog),
544 .animation_frames = anim_dog,
545 .hitbox = { { FIXED_INT_I(1), FIXED_INT_I(1) },
546 { FIXED_INT_I(6), FIXED_INT_I(4) } },
547 .spawn_inertia = { FIXED_POINT_I(0, -200), FIXED_POINT_I(0, 0) },
548 .collision_tiles = enemy_collision_tiles_bounce_horiz,
549 .collision_player = enemy_collision_player_jumpable,
550 .collision_shots = enemy_collision_shots_die,
551 .move_tick = enemy_tick_dog
552 }, {
553 .animation_ticks_per_frame = 36,
554 .animation_length = ARRAY_SIZE(anim_giraffe),
555 .animation_frames = anim_giraffe,
556 .hitbox = { { FIXED_INT_I(2), FIXED_INT_I(1) },
557 { FIXED_INT_I(4), FIXED_INT_I(9) } },
558 .spawn_inertia = { FIXED_POINT_I(0, -150), FIXED_POINT_I(-1, -200) },
559 .collision_tiles = enemy_collision_tiles_bounce_horiz,
560 .collision_player = enemy_collision_player_jumpable,
561 .collision_shots = enemy_collision_shots_bounce,
562 .move_tick = enemy_tick_giraffe
563 }, {
564 .animation_ticks_per_frame = 24,
565 .animation_length = ARRAY_SIZE(anim_bird),
566 .animation_frames = anim_bird,
567 .hitbox = { { FIXED_INT_I(1), FIXED_INT_I(3) },
568 { FIXED_INT_I(7), FIXED_INT_I(3) } },
569 .spawn_inertia = { FIXED_POINT_I(0, -400), FIXED_POINT_I(0, -150) },
570 .collision_tiles = enemy_collision_tiles_bounce_horiz,
571 .collision_player = enemy_collision_player_jumpable,
572 .collision_shots = enemy_collision_shots_die,
573 .move_tick = enemy_tick_swing_up_and_down
574 }, {
575 .animation_ticks_per_frame = 24,
576 .animation_length = ARRAY_SIZE(anim_bird),
577 .animation_frames = anim_bird,
578 .hitbox = { { FIXED_INT_I(1), FIXED_INT_I(3) },
579 { FIXED_INT_I(7), FIXED_INT_I(3) } },
580 .spawn_inertia = { FIXED_POINT_I(0, -400), FIXED_INT_I(0) },
581 .collision_tiles = enemy_collision_tiles_bounce_horiz,
582 .collision_player = enemy_collision_player_jumpable,
583 .collision_shots = enemy_collision_shots_die,
584 .move_tick = enemy_tick_fly_straight
585 }, {
586 .animation_ticks_per_frame = 24,
587 .animation_length = ARRAY_SIZE(anim_bird),
588 .animation_frames = anim_bird,
589 .hitbox = { { FIXED_INT_I(1), FIXED_INT_I(3) },
590 { FIXED_INT_I(7), FIXED_INT_I(3) } },
591 .spawn_inertia = { FIXED_POINT_I(0, -400), FIXED_POINT_I(0, 200) },
592 .collision_tiles = enemy_collision_tiles_bounce_horiz,
593 .collision_player = enemy_collision_player_jumpable,
594 .collision_shots = enemy_collision_shots_die,
595 .move_tick = enemy_tick_fly_straight_and_dip
596 }
597 };
This page took 0.074135 seconds and 5 git commands to generate.