1cf8f069f7d23b05687284454de6e454eaf10a20
[hackover2013-badge-firmware.git] / badge / jumpnrun / enemies.h
1 #ifndef INCLUDED_JUMPNRUN_ENEMIES_H
2 #define INCLUDED_JUMPNRUN_ENEMIES_H
3
4 #include "../ui/sprite.h"
5 #include "../util/rectangle.h"
6
7 #include "moveable.h"
8 #include "tiles.h"
9
10 struct jumpnrun_game_state;
11 struct jumpnrun_level;
12 struct jumpnrun_tile_range;
13
14 struct jumpnrun_enemy;
15
16 typedef struct jumpnrun_enemy_type {
17 unsigned animation_ticks_per_frame;
18 size_t animation_length;
19 badge_sprite const *animation_frames;
20
21 rectangle hitbox;
22 vec2d spawn_inertia;
23
24 void (*collision_tiles)(struct jumpnrun_enemy *self,
25 vec2d *desired_position,
26 struct jumpnrun_level *lv,
27 struct jumpnrun_tile_range const *visible_tiles);
28 void (*collision_player)(struct jumpnrun_enemy *self,
29 struct jumpnrun_game_state *state,
30 vec2d *player_inertia_mod);
31 void (*collision_shots)(struct jumpnrun_enemy *self,
32 struct jumpnrun_game_state *state);
33
34 void (*move_tick)(struct jumpnrun_enemy *self,
35 struct jumpnrun_game_state *state,
36 struct jumpnrun_level *lv,
37 struct jumpnrun_tile_range const *visible_tiles,
38 vec2d *player_inertia_mod);
39 } jumpnrun_enemy_type;
40
41 typedef struct jumpnrun_enemy {
42 jumpnrun_moveable base;
43 vec2d spawn_pos;
44
45 jumpnrun_enemy_type const *type;
46 } jumpnrun_enemy;
47
48 enum {
49 // Do not collide with JUMPNRUN_MOVEABLE_* flags
50 JUMPNRUN_ENEMY_SPAWNED = 4,
51 JUMPNRUN_ENEMY_UNAVAILABLE = 8,
52 JUMPNRUN_ENEMY_EVENT_TRIGGER1 = 128
53 };
54
55 static inline rectangle const *enemy_hitbox(jumpnrun_enemy const *enemy) { return &enemy->base.hitbox; }
56 void jumpnrun_enemy_despawn(jumpnrun_enemy *self);
57 void jumpnrun_enemy_reset (jumpnrun_enemy *self);
58
59 enum {
60 JUMPNRUN_ENEMY_TYPE_CAT,
61 JUMPNRUN_ENEMY_TYPE_MUSHROOM,
62 JUMPNRUN_ENEMY_TYPE_BUNNY,
63 JUMPNRUN_ENEMY_TYPE_SNAKE,
64 JUMPNRUN_ENEMY_TYPE_SPIRAL,
65 JUMPNRUN_ENEMY_TYPE_ROTOR,
66 JUMPNRUN_ENEMY_TYPE_DOG,
67 JUMPNRUN_ENEMY_TYPE_GIRAFFE,
68 JUMPNRUN_ENEMY_TYPE_BIRD,
69 JUMPNRUN_ENEMY_TYPE_BIRD_STRAIGHT,
70 JUMPNRUN_ENEMY_TYPE_BIRD_DIP,
71
72 JUMPNRUN_ENEMY_TYPE_COUNT
73 };
74
75 extern jumpnrun_enemy_type const jumpnrun_enemy_type_data[JUMPNRUN_ENEMY_TYPE_COUNT];
76
77 void jumpnrun_process_enemy(jumpnrun_enemy *self,
78 badge_framebuffer *fb,
79 struct jumpnrun_game_state *state,
80 struct jumpnrun_level *lv,
81 struct jumpnrun_tile_range const *visible_tiles,
82 vec2d *player_inertia_mod);
83 #endif
This page took 0.047202 seconds and 3 git commands to generate.